首页 > 解决方案 > AttributeError:“顺序”对象没有属性“_feed_input_names”

问题描述

我正在使用 python 2.7.5遵循tf.keras教程model.fit(data, labels, epochs=10, batch_size=32),但给了我错误消息:

>>> model.fit(data, labels, epochs=10, batch_size=32,validation_data=    (val_data, val_labels))

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/software/TensorFlow/1.8-GPU-py2/lib/python2.7/site-packages/tensorflow/python/keras/_impl/keras/engine/training.py", line 1143, in fit
    batch_size=batch_size)
  File "/software/TensorFlow/1.8-GPU-py2/lib/python2.7/site-packages/tensorflow/python/keras/_impl/keras/engine/training.py", line 751, in _standardize_user_data
    feed_input_names = self._feed_input_names
AttributeError: 'Sequential' object has no attribute '_feed_input_names'

谁能指出什么是错的?

标签: tensorflowkeras

解决方案


我有同样的问题,不知道为什么,我没有搜索它,但是当我将这个参数 input_shape=(height,width,channels)添加到我的第一层网络时,错误就消失了。

model = keras.models.Sequential()
model.add(firstLayer(....., input_shape=(height,width,channels))

我希望它也能帮助你。


推荐阅读