首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何提高num_classes在ssd_mobilenet_v1流量中的应用

如何提高num_classes在ssd_mobilenet_v1流量中的应用
EN

Stack Overflow用户
提问于 2020-07-28 15:44:16
回答 1查看 238关注 0票数 2

我正在使用ssd_mobilenet_v1_coco.config和

经过计划培训后,我将num_classes的值改为20,增加了13件东西。

代码语言:javascript
复制
python model_main.py --alsologtostderr --model_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_coco.config

我一直试着用命令学习,但我遇到了一个错误。要增加num_classes,我应该做什么?我应该从一开始就抓起num_classes=100吗?我需要帮助。

代码语言:javascript
复制
model {
  ssd {
    num_classes: 20
    box_coder {
      faster_rcnn_box_coder {
        y_scale: 10.0
        x_scale: 10.0
        height_scale: 5.0
        width_scale: 5.0
      }


  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/training/saver.py", line 1326, in restore
    err, "a mismatch between the current graph and the graph")
tensorflow.python.framework.errors_impl.InvalidArgumentError: 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. Original error:

Assign requires shapes of both tensors to match. lhs shape= [126] rhs shape= [84]
         [[node save/Assign_56 (defined at /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py:1748) ]]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-16 13:49:51

我最近也遇到了类似的问题。为了解决我的问题,我必须做以下工作:

  • 在pipeline.config的train_config部分,让fine_tune_checkpoint指向以前的模型检查点。"./model/model.ckpt"
  • In model_main.py命令调用,使model_dir引用与上一个检查点不同的文件夹:

代码语言:javascript
复制
python research/object_detection/model_main.py \
  --model_dir=./model/finetune0 \
  --pipeline_config_path=./model/pipeline.config \
  --alsologtostderr

我的档案结构:

代码语言:javascript
复制
+ models
-+ model
--+ checkpoint
--+ model.ckpt.index
--+ model.ckpt.meta
--+ model.ckpt.data-00000-of-00001
--+ pipeline.config
--- finetune0 (will be autogenerated)

-- data (tfrecord dataset)
-- annotations (labels)
...

上下文

看起来,当您已经在model_dir上有一个检查点时,脚本将尝试恢复对所提供的模型的培训,但是pipeline.config上的新配置将与当前模型不匹配(num_class不同)。

如果您在fine_tune_checkpoint中提供了这个检查点并将model_dir指向一个新文件夹,它将从检查点变量构建模型,调整它以匹配新的配置,然后开始培训。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63137975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档