AttributeError:"NoneType"对象在keras resnet50中没有属性"image_data_format" [英] AttributeError: 'NoneType' object has no attribute 'image_data_format' in keras resnet50
本文介绍了AttributeError:"NoneType"对象在keras resnet50中没有属性"image_data_format"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Resnet50模型进行培训.
I am trying to use Resnet50 model for training.
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'
推荐答案
我也遇到了这个问题.
请尝试一下.效果很好:
Please try this. It works very well:
from keras.applications.resnet50 import ResNet50
这篇关于AttributeError:"NoneType"对象在keras resnet50中没有属性"image_data_format"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文