我正在尝试调整示例重新训练脚本(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 …