Assign requires shapes of both tensors to match.

本文详细解析了在使用SSD进行目标检测训练时遇到的“形状不匹配”错误,提供了三种有效的解决策略,包括清理旧检查点、确保标签与类别数一致及回滚代码版本,帮助读者快速定位并解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [12] rhs shape= [84]

在配置SSD进行训练自己的数据集时出现的问题.

查找到的解决方案有:

(1)Try deleting any checkpoints that were saved from previous runs. Sometimes when changing the architecture and running again, TF will pick up from the old checkpoint (but with new definition), and you get this error.

(2)I also ran into this problem, the problem was that the labels and class numbers didn't matched so I changed and fix the class number cound and labels everywhere.In my case it was to change the "num_classes" parameter in the faster_rcnn.config and the "label_map.pbtxt" file to match with the real values.

(3)So as it happens, I had updated the TensorFlow code but had failed to train it. So I rolled back to the previous version, made the appropriate new changes to the run script and got it working.

经过排查与尝试,最终发现是自己的标签问题,我自己训练的是3类,而SSD原始代码是21类,而我只改了部分地方,因此只需要将代码里的类别全部改成3即可.

参考:https://stackoverflow.com/questions/40601975/tensorflow-assign-requires-shapes-of-both-tensors-to-match-lhs-shape-20-rhs

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值