Keras:创建MobileNet_V2模型"AttributeError"; [英] Keras : Create MobileNet_V2 model "AttributeError"
问题描述
我已经使用keras成功地基于mobileNet构建了多个模型.我注意到在Keras 2.2.0中添加了MobileNet_V2,但是我无法使其正常工作:
I have successfully built several model based on mobileNet using keras. I noticed that MobileNet_V2 as been added in Keras 2.2.0, but I could not manage to make it work :
from keras.applications.mobilenet_v2 import mobilenet_v2
base_model = mobilenet_v2.MobileNetV2(weights='imagenet', include_top=False)
我从mobilenet_v2.py data_format=backend.image_data_format()
I get the following error : AttributeError: 'NoneType' object has no attribute 'image_data_format'
on this line from mobilenet_v2.py data_format=backend.image_data_format()
在我看来backend
存在定义问题...我正在使用Tensorflow后端,也许它不适用于此后端?
It seems to me that backend
has a definition problem... I am using Tensorflow backend, maybe it does not work with this one ?
推荐答案
问题来自导入.正确的方法是执行以下操作:
The problem is from the import. The proper way to do this is to do the following :
from keras.applications import MobileNetV2
m = MobileNetV2(weights='imagenet', include_top=False)
这篇关于Keras:创建MobileNet_V2模型"AttributeError";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!