TypeError:sigmoid_cross_entropy_with_logits()得到了一个意外的关键字参数'标签'编译CNN时

时间:2017-12-04 05:05:58

标签: python tensorflow typeerror

在使用tensorflow编译卷积神经网络时,我在Python中遇到了TypeError。我尝试更新tensorflow,但我仍然遇到TypeError。这是我收到的错误消息:

# Compiling CNN
classifier.compile(optimizer='adam', loss='binary_crossentropy', metrics=
['accuracy'])
classifier.compile(optimizer='adam', loss='binary_crossentropy', metrics=
['accuracy'])
Traceback (most recent call last):

  File "<ipython-input-12-003b5eeaec4a>", line 1, in <module>
  classifier.compile(optimizer='adam', loss='binary_crossentropy', 
  metrics=['accuracy'])

  File "C:\Users\Arunachalam\Anaconda3\envs\tensorflow\lib\site-
  packages\keras\models.py", line 821, in compile
    **kwargs)

  File "C:\Users\Arunachalam\Anaconda3\envs\tensorflow\lib\site-
  packages\keras\engine\training.py", line 860, in compile
    sample_weight, mask)

  File "C:\Users\Arunachalam\Anaconda3\envs\tensorflow\lib\site-
  packages\keras\engine\training.py", line 459, in weighted
  score_array = fn(y_true, y_pred)

  File "C:\Users\Arunachalam\Anaconda3\envs\tensorflow\lib\site-
  packages\keras\losses.py", line 68, in binary_crossentropy
  return K.mean(K.binary_crossentropy(y_true, y_pred), axis=-1)

  File "C:\Users\Arunachalam\Anaconda3\envs\tensorflow\lib\site-
  packages\keras\backend\tensorflow_backend.py", line 2947, in 
  binary_crossentropy
  logits=output)

  TypeError: sigmoid_cross_entropy_with_logits() got an unexpected keyword 
  argument 'labels'

1 个答案:

答案 0 :(得分:-1)

当我使用Tensorflow r0.11时,我得到了相同的TypeError。将Tensorflow升级到1.3.0后,TypeError消失了。