试图重新训练张量流模型,输入和输出节点消失

时间:2018-09-05 04:21:25

标签: tensorflow

我正在尝试使用MobileNet_V2重新训练Tensorflow Deeplab模型。我已经从Deeplab模型动物园下载了检查点,大约在此页面的一半以下: https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md 具体来说,mobilenetv2_coco_voc_trainaug一个。我希望重新训练的输出具有相同的图形,但与此参数不同。 (好吧,几乎是同一张图,最终张量可能应该具有不同的形状,因为我正尝试使用不同数量的类。)

我将自己的图像组装到一个tfrecord中,目前只标记了一个类。这是针对具有4个类的数据集的实践。

然后我运行以下命令来重新训练网络,生成.pbtxt.meta.index.data-00000-of-00001文件:

PATH_TO_INITIAL_CHECKPOINT=/path/to/unzipped/files/model.ckpt-30000.index
PATH_TO_TRAIN_DIR=/path/to/checkpoints/
PATH_TO_DATASET=/path/to/tfrecord
python /path/to/tensorflow/models/research/deeplab/train.py \
    --logtostderr \
    --training_number_of_steps=900 \ # 90000 \
    --train_split="train" \
    --model_variant="mobilenet_v2" \
    --output_stride=16 \
    --decoder_output_stride=4 \
    --train_crop_size=128 \
    --train_crop_size=128 \
    --train_batch_size=1 \
    --dataset="cityscapes" \
    --tf_initial_checkpoint=${PATH_TO_INITIAL_CHECKPOINT} \
    --train_logdir=${PATH_TO_TRAIN_DIR} \
    --dataset_dir=${PATH_TO_DATASET} \
    --initialize_last_layer=False \
    --last_layers_contain_logits_only=True \
    --fine_tune_batch_norm=False

在下载的文件上运行bazel的summary_graph可以得出:

Found 1 possible inputs: (name=ImageTensor, type=uint8(4), shape=[1,?,?,3]) 
No variables spotted.
Found 1 possible outputs: (name=SemanticPredictions, op=Slice) 

当我扫描.pbtxt文件的节点时,找不到名为ImageTensor或SemanticPredictions的节点。我已经尝试过使用tensorboard,bazel的summary_graph和以编程方式(例如hereherehere)进行尝试。 Summarize_graph说No inputs spottedFound 664 possible outputs:

这将导致freeze_graph.py出现问题。如果我从tensorbord上看到的内容中选择output_node_names,那么freeze_graph.py就会运行,并且可以得到冻结的图形。但是运行该模型可以给我

TypeError: Cannot interpret feed_dict key as Tensor: The name 
'ImageTensor:0' refers to a Tensor which does not exist. The operation, 
'ImageTensor', does not exist in the graph.

我肯定在这里做错了。问题是:什么?我怀疑这可能是我提供给train.py的参数,但实际上,这只是黑暗中的一枪。可能这不是打算使用train.py的方式,或者deeplab的train.py与MobileNetV2不兼容。

编辑:仔细查看train.py中提供的选项后,我已经更新了命令。从TRAIN_DIR清除先前失败的模型也有助于避免该错误:

Restoring from checkpoint failed. This is most likely due to a mismatch 
between the current graph and the graph from the checkpoint. Please ensure 
that you have not altered the graph expected based on the checkpoint.

0 个答案:

没有答案