您的位置:首页 > 大数据 > 人工智能

用mobilenet模型跑tensorflow CNN的样例:image_retrain.py和label_image.py

2018-03-16 00:46 369 查看
系统是 ubuntu 16.04,tensorflow版本是1.6, cuDNN版本是7.0。git clone tensorflow后试着跑了一下image_retrain.py(以下简称retrain)和label_image.py(以下简称label)。retain训练新的mobilenet分类器成功,用label测试新分类器也成功。但是用label在tensorflow 1.4以下的环境中测试新分类器中出错。错误提示如下:

> InvalidArgumentError (see above for traceback): NodeDef mentions attr
> 'dilations' not in Op<name=Conv2D; signature=input:T, filter:T ->
> output:T; attr=T:type,allowed=[DT_HALF, DT_FLOAT];
> attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true;
> attr=padding:string,allowed=["SAME", "VALID"];
> attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]>;
> NodeDef: import/MobilenetV1/MobilenetV1/Conv2d_0/Conv2D =
> Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1],
> padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true,
> _device="/job:localhost/replica:0/task:0/device:GPU:0"](_arg_import/input_0_0/_1,
> import/MobilenetV1/Conv2d_0/weights). (Check whether your
> GraphDef-interpreting binary is up to date with your
> GraphDef-generating binary.).      [[Node:
> import/MobilenetV1/MobilenetV1/Conv2d_0/Conv2D = Conv2D[T=DT_FLOAT,
> data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME",
> strides=[1, 2, 2, 1], use_cudnn_on_gpu=true,
> _device="/job:localhost/replica:0/task:0/device:GPU:0"](_arg_import/input_0_0/_1,
> import/MobilenetV1/Conv2d_0/weights)]]


而且在tensorflow 1.4的环境下,运行image_retrain.py(更新日期为2018年2月28日)也报错。

读代码可知,新retain下载的mobilenet地址是

data_url = 'http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/'


旧retrain下载的mobilenet的地址是

data_url = 'http://download.tensorflow.org/models/mobilenet_v1_'


而且根据github上的image_retain.py文件描述
Modify retrain script to output TFLite compatible quantized models.


大致可以猜测到新的mobilenet由tensorflow 1.6构造,已经不兼容tensorflow 1.4了。

所以,由于种种原因不能升级到tensorflow 1.6版本的同学,要把老版本的mobilenet和image_retrain.py留好了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: