我正在尝试调整示例重新训练脚本(https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py)以使用Inception V4模型.
该脚本已经支持重新启动Inception V3(2015)以及不同版本的Mobilenet.
到目前为止我做了什么:由于脚本使用protobuf(.pb)文件而不是检查点(.ckpt),我inception_v4.pb从这里下载了:https://deepdetect.com/models/tf/inception_v4.pb .据我所知,还可以加载检查点并使用冻结图工具获取相同的文件.
然后,我使用tensorflow python工具查看了tensorboard中的图形,该工具import_pb_to_tensorboard.py可以在tensorflow github存储库中找到.从那里(纠正我,如果我没看错),我发现,resized_input_tensor_name被称为InputImage,而bottleneck_tensor_name为InceptionV4/Logits/Logits/MatMul与bottleneck_tensor_size是1001.
有了这些信息,我尝试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:无法将操作转换为张量).
小智 5
我目前正在处理同一件事。
尝试添加:0到您bottleneck_tensor_name和您的广告的末尾resized_input_tensor_name。
如果您在中注意到retrain.py,Google也会使用此:0命名法。
我的怀疑是,对您来说,InceptionV4/Logits/Logits/MatMul这只是一个操作,您不想为该脚本获取,而您InceptionV4/Logits/Logits/MatMul:0是从该操作实例化的第一个张量,而您想为该脚本获取。
| 归档时间: |
|
| 查看次数: |
3810 次 |
| 最近记录: |