【问题标题】:AttributeError: 'NoneType' object has no attribute 'image_data_format' in keras resnet50AttributeError:'NoneType'对象在keras resnet50中没有属性'image_data_format'
【发布时间】:2019-01-06 19:04:31
【问题描述】:

我正在尝试使用 Resnet50 模型进行训练。

from keras import backend as K
from keras_applications.resnet50 import ResNet50
from keras.layers import Input
from keras.callbacks import ModelCheckpoint

K.set_image_data_format('channels_last')
K.set_image_dim_ordering('tf')

input_layer = Input(shape=(224, 224, 3))
model = ResNet50(include_top=True, weights=None, classes=2)
model.compile(optimizer='rmsprop', loss='binary_crossentropy', metrics=['accuracy'])

为什么会出现以下错误?

Using TensorFlow backend.
Traceback (most recent call last):
File "model.py", line 42, in <module>
model = ResNet50(include_top=True, weights=None, input_tensor=input_layer, classes=2)
File "/home/mario/.local/lib/python3.6/site-packages/keras_applications/resnet50.py", line 209, in ResNet50
data_format=backend.image_data_format(),
AttributeError: 'NoneType' object has no attribute 'image_data_format'

【问题讨论】:

  • 更新你的 tensorflow 和 Keras!它工作正常。
  • 我有最新版本

标签: python-3.x tensorflow keras


【解决方案1】:

我也遇到了这个问题。

请试试这个。效果很好:

from keras.applications.resnet50 import ResNet50

【讨论】:

    【解决方案2】:

    我遇到了类似的问题。它通过将keras_applications 更改为keras.applications 来工作。

    他们在 GitHub 上有一个问题,但仍然打开:https://github.com/keras-team/keras-applications/issues/54

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-08
      • 1970-01-01
      • 2019-01-01
      相关资源
      最近更新 更多