繁体   English   中英

在重新训练的例子中使用初始v4

[英]Using inception v4 in retrain example

我正在尝试调整示例重新训练脚本( https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py )以使用Inception V4模型。

该脚本已经支持重新启动Inception V3(2015)以及不同版本的Mobilenet。

到目前为止我做了什么:由于脚本使用protobuf(.pb)文件而不是检查点(.ckpt),我从这里下载了inception_v4.pbhttps ://deepdetect.com/models/tf/inception_v4.pb 。 据我所知,还可以加载检查点并使用冻结图工具获取相同的文件。

然后,我使用tensorflow python工具import_pb_to_tensorboard.py查看了tensorboard中的图形,该工具可以在tensorflow github存储库中找到。 从那里(纠正我,如果我没有错)我发现resized_input_tensor_name被称为InputImagebottleneck_tensor_nameInceptionV4/Logits/Logits/MatMul其中bottleneck_tensor_size1001

有了这些信息,我尝试通过添加以下内容来调整重新训练脚本的create_model_info(architecture)功能:

elif architecture == 'inception_v4':
        data_url = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz' #this won't make any difference
        bottleneck_tensor_name = 'InceptionV4/Logits/Logits/MatMul'
        bottleneck_tensor_size = 1001
        input_width = 299
        input_height = 299
        input_depth = 3
        resized_input_tensor_name = 'InputImage'
        model_file_name = 'inception_v4.pb'
        input_mean = 128
        input_std = 128

我使用以下命令运行脚本:

python retrain.py --architecture=inception_v4 --bottleneck_dir=test2/bottlenecks --model_dir=inception_v4 --summaries_dir=test2/summaries/basic --output_graph=test2/graph_flowers.pb --output_labels=test2/labels_flowers.txt --image_dir=datasets/flowers/flower_photos --how_many_training_steps 100

我收到以下错误:

文件“retrain.py”,第373行,在create_bottleneck_file str(e)中))RuntimeError:处理文件数据集/ flowers / flower_photos / tulips / 4546299243_23cd58eb43.jpg时出错(无法将feed_dict键解释为Tensor:无法将操作转换为张量)。

我目前正在做同样的事情。

尝试在您的bottleneck_tensor_nameresized_input_tensor_name的末尾添加:0

如果您在retrain.pyretrain.py ,Google也会使用:0命名法。

我怀疑,对于你来说, InceptionV4/Logits/Logits/MatMul只是一个操作,你不会试图获得这个脚本,而InceptionV4/Logits/Logits/MatMul:0是从该操作实例化的第一个张量,您正试图获得此脚本。

将此修改添加到您的脚本然后将InputImage视为Tensor:

resized_input_tensor_name = 'InputImage:0'

暂无
暂无

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

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