信用卡逻辑回归报错

代码:

import pandas as pd
import tensorflow as tf
import matplotlib as plt

data=pd.read_csv("datasets/credit-a.csv",header=None)
print(data.head())

print(data.iloc[:,-1].value_counts())#.iloc[]与loc一样,中括号里面也是先行后列,行列标签用逗号分割
#data.iloc[:,-1].replace(-1,0)
x=data.iloc[:,:-1]#所有行,除了最后一列的所有列
y=data.iloc[:,-1].replace(-1,0)#用0替换掉改列所有的-1

model=tf.keras.Sequential()
model.add(tf.keras.layers.Dense(4,input_shape=(15,),activation='relu'))
model.add(tf.keras.layers.Dense(4,activation='relu'))
model.add(tf.keras.layers.Dense(1,activation='sigmoid'))
model.summary()
print("-----------------")
model.compile(optimizer='adam',loss='binary_crossentropy',metircs=['acc'])
history=model.fit(x,y,epochs=100)
history.history.keys()

plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epochs')
plt.plot(history.epoch,history.history.get('loss'))
plt.show()

#model.evaluate(x,y)

报错:

D:\Python\Anaconda3\python.exe D:/Python/workspace/Deeplearning/tensorflow2/Logisticsregression.py

   0      1      2   3   4   5   6     7   8   9   10  11  12   13     14  15

0   0  30.83  0.000   0   0   9   0  1.25   0   0   1   1   0  202    0.0  -1

1   1  58.67  4.460   0   0   8   1  3.04   0   0   6   1   0   43  560.0  -1

2   1  24.50  0.500   0   0   8   1  1.50   0   1   0   1   0  280  824.0  -1

3   0  27.83  1.540   0   0   9   0  3.75   0   0   5   0   0  100    3.0  -1

4   0  20.17  5.625   0   0   9   0  1.71   0   1   0   1   2  120    0.0  -1

 1    357

-1    296

Name: 15, dtype: int64

2019-11-22 16:51:11.891738: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

Model: "sequential"

_________________________________________________________________

Layer (type)                 Output Shape              Param #   

=================================================================

dense (Dense)                (None, 4)                 64        

_________________________________________________________________

dense_1 (Dense)              (None, 4)                 20        

_________________________________________________________________

dense_2 (Dense)              (None, 1)                 5         

=================================================================

Total params: 89

Trainable params: 89

Non-trainable params: 0

_________________________________________________________________

-----------------

WARNING:tensorflow:Falling back from v2 loop because of error: Failed to find data adapter that can handle input: <class 'pandas.core.frame.DataFrame'>, <class 'NoneType'>

Traceback (most recent call last):

  File "D:/Python/workspace/Deeplearning/tensorflow2/Logisticsregression.py", line 20, in <module>

    history=model.fit(x,y,epochs=100)

  File "D:\Python\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 728, in fit

    use_multiprocessing=use_multiprocessing)

  File "D:\Python\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training_arrays.py", line 674, in fit

    steps_name='steps_per_epoch')

  File "D:\Python\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training_arrays.py", line 189, in model_iteration

    f = _make_execution_function(model, mode)

  File "D:\Python\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training_arrays.py", line 565, in _make_execution_function

    return model._make_execution_function(mode)

  File "D:\Python\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 2184, in _make_execution_function

    self._make_train_function()

  File "D:\Python\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 2133, in _make_train_function

    **self._function_kwargs)

  File "D:\Python\Anaconda3\lib\site-packages\tensorflow_core\python\keras\backend.py", line 3772, in function

    'eager execution. You passed: %s' % (kwargs,))

ValueError: Session keyword arguments are not support during eager execution. You passed: {'metircs': ['acc']}


Process finished with exit code 1



qq_莫非
浏览 3661回答 0
0回答

慕斯4360584

VLHAKRYWJCFHQFIYORZMZMPINYGZFIFJPHYXDDTMNAXDCICOXDNROLRQDGSYVIROYYAJZKGAQMJGDNZPFYRLUOEHUUQWCZVPFCAZZYUVEUIIBLZSLJPDNDNANLFLLZSOEBUOYHWVREUUOLEXGFIRBVVLWWUDJPVCIEBVBNNATYURKDRQEQOHLIBLEBIISWPCYVSILRNNDCJTGTGEDDQFZPIMMJEYVUJMWEBHKCFTOKHNYLYREBPIYXOOXNTHFDFRXHKAAQQXIEAQK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