【问题标题】:Failed on freeze graph for resnet_v1_50 using TF-slim使用 TF-slim 冻结 resnet_v1_50 的图失败
【发布时间】:2018-11-28 08:47:27
【问题描述】:

我想冻结模型并部署它们。我首先遵循了来自12 的slim 附带的教程,使用InceptionV3,效果很好。然后我尝试对从the provided url 下载的 resnet_v1_50 执行相同的操作。

任何建议将不胜感激!

谢谢!

以下是步骤:

cd /path/to/tensorflow-models/research/slim
# export inference graph, success
python export_inference_graph.py --alsologtostderr --model_name=resnet_v1_50 --output_file=resnet_v1_50_inf_graph.pb
# freeze the inference graph with the trained weights, failed
python ~/.local/lib/python2.7/site-packages/tensorflow/python/tools/freeze_graph.py \
    --input_graph=resnet_v1_50_inf_graph.pb \
    --input_checkpoint=/path/to/models/resnet_v1_50.ckpt \
    --input_binary=true --output_graph=frozen_resnet_v1_50.pb \
    --output_node_names=resnet_v1_50/predictions/Reshape

错误消息太长,我重定向一个以引用它here

【问题讨论】:

    标签: python python-2.7 tensorflow tensorflow-serving


    【解决方案1】:

    如下行所示,导出推理图时应将labels_offset 设置为1

    InvalidArgumentError (see above for traceback): Assign requires shapes of both 
    tensors to match. lhs shape= [1001] rhs shape= [1000]
         [[Node: save/Assign_265 = Assign[T=DT_FLOAT, _class= . 
    ["loc:@resnet_v1_50/logits/biases"], use_locking=true, validate_shape=true, 
    _device="/job:localhost/replica:0/task:0/device:GPU:0"](resnet_v1_50/logits/biases, 
    save/RestoreV2_265/_1)]]
    

    命令如下:

    python export_inference_graph.py --model_name=resnet_v1_50 --labels_offset=1 --output_file=resnet_v1_50_inf_graph.pb
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-06
      • 2017-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多