繁体   English   中英

AttributeError:“ NoneType”对象在keras resnet50中没有属性“ image_data_format”

[英]AttributeError: 'NoneType' object has no attribute 'image_data_format' in keras resnet50

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

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

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

我也遇到了这个问题。

请尝试这个。 效果很好:

from keras.applications.resnet50 import ResNet50

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM