tensorflow - 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'
谁能指出什么是错的?
解决方案
我有同样的问题,不知道为什么,我没有搜索它,但是当我将这个参数 input_shape=(height,width,channels)添加到我的第一层网络时,错误就消失了。
model = keras.models.Sequential()
model.add(firstLayer(....., input_shape=(height,width,channels))
我希望它也能帮助你。
推荐阅读
- swift - 如何从 SwiftUI 中的函数返回枚举?
- c# - 模式弹出窗口未显示 runat=server on
- flask - 在烧瓶中创建数据库时如何在烧瓶-sqlalchemy中自动插入一行
- xcode - 在导航中转换到根标签栏控制器 XCODE
- php - 如何将 PHP 生成的 PNG 图像插入到我的 html 中?
- dataframe - 如何使用一个 np.where 语句更新数据框 A 的 3 列和数据框 B 的 3 列
- mysql - MySQL:第一次查询慢得多,但之后即使插入新数据也更快
- docker - spark在pod上运行时如何利用kubernetes的节点?
- python - 使用 Selenium 在网页上查找“登录”按钮
- apache-spark - pyspark 使用用户指定的模式读取 csv - 返回所有 StringType