属性错误:'Sequential'对象没有属性'_feed_input_names'。

3

我正在使用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'

有人能指出问题在哪里吗?


当我使用 tf.keras 时,我看到的错误类型非常奇怪。我可能会尝试使用原始的 keras。 - Daniel Möller
1个回答

2
我遇到了相同的问题,不确定原因。我没有搜索它,但是当我在网络的第一层添加了这个参数input_shape=(height,width,channels)时,错误就消失了。翻译成中文为:"我遇到了相同的问题,但不确定原因。我没有搜索过,但是当我在网络的第一层中加入这个参数input_shape=(高度、宽度、通道数)时,错误就消失了。"
model = keras.models.Sequential()
model.add(firstLayer(....., input_shape=(height,width,channels))

最初的回答
希望这对您有所帮助。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接