为了账号安全,请及时绑定邮箱和手机立即绑定

信用卡逻辑回归报错

信用卡逻辑回归报错

代码: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  150   0  30.83  0.000   0   0   9   0  1.25   0   0   1   1   0  202    0.0  -11   1  58.67  4.460   0   0   8   1  3.04   0   0   6   1   0   43  560.0  -12   1  24.50  0.500   0   0   8   1  1.50   0   1   0   1   0  280  824.0  -13   0  27.83  1.540   0   0   9   0  3.75   0   0   5   0   0  100    3.0  -14   0  20.17  5.625   0   0   9   0  1.71   0   1   0   1   2  120    0.0  -1 1    357-1    296Name: 15, dtype: int642019-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: AVX2Model: "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: 89Trainable params: 89Non-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
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 3660 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信