• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

信用卡逻辑回归报错

代码:

import pandas as pdimport tensorflow as tfimport matplotlib as pltdata=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替换掉改列所有的-1model=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: ,
Traceback (most recent call last):
  File "D:/Python/workspace/Deeplearning/tensorflow2/Logisticsregression.py", line 20, in
    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

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

发新帖

发布任务需求已有1031166位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!