ValueError: Shape mismatch: The shape of labels (received (768,)) should equal the shape of logits e
问题
运行tensorflow 的resnet网络,预测结果,出现报错
ValueError: Shape mismatch: The shape of labels (received (768,)) should equal the shape of logits e
原因
解决:use of sparse_softmax_cross_entropy. feed it one hot encoded labels which it doesn’t want.
Switch to just normal softmax_cross_entropy and see if that works.
这个问题是由于输出层的类别数和训练数据shape不同导致。
在训练模型时,一般会将label使用one hot编码,然后模型的loss使用交叉熵:
解决方法
Use this crossentropy loss function when there are two or more label classes. We expect labels to be provided in a one_hot representation. If you want to provide labels as integers, please use SparseCategoricalCrossentropy loss. There should be # classes floating point values per feature.
修改sparse_categorical_crossentropy为ategorical_crossentropy
ValueError: Shape mismatch: The shape of labels (received (768,)) should equal the shape of logits e相关推荐
- 成功解决IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (100,)
成功解决IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (100,) 目 ...
- Cannot copy param 0 weights from layer 'fc6'; shape mismatch.
问题: Cannot copy param 0 weights from layer 'fc6'; shape mismatch. Source param shape is 4096 9216 (3 ...
- 超分辨率分割SLIC算法实现过程遇到的问题,shape mismatch: value array of shape (3,) could not be broadcast to indexing
超分辨率分割SLIC算法实现过程遇到的问题 shape mismatch: value array of shape (3,) could not be broadcast to indexing r ...
- size mismatch for roi_heads.box_predictor.cls_score.weight: copying a param with shape torch.Size([9
1. 报错 RuntimeError: Error(s) in loading state_dict for FasterRCNN: size mismatch for roi_heads.box_p ...
- ValueError: mode mismatch
项目场景:PIL库Image模块处理数组合并成3通道RGB图像 项目中,使用Pytorch的torch.utils.data.DataLoader加载自己准备好的数据集.同时想要直观查看或验证生成的数 ...
- valueError: Length mismatch: Expected axis has 40 elements, new values have 38 elements
背景 我拿原来的模型准备跑一个新数据集,当然列就会不同 新数据集没有head,我就自己傻乎乎一个一个数的列数(应该是数错了 我原来数的38其实是40) 就报了valueError: Length mi ...
- 成功解决 ValueError: feature_names mismatch training data did not have the following fields
成功解决 ValueError: feature_names mismatch training data did not have the following fields 目录 解决问题 解决思路 ...
- 编写一个抽象类Shape,声明计算图形面积的抽象方法。再分别定义Shape的子类Circle(圆)和Rectangle(矩形),在两个子类中按照不同图形的面积计算公式,实现Shape类中计算面积的方法
编写一个抽象类Shape,声明计算图形面积的抽象方法.再分别定义Shape的子类Circle(圆)和Rectangle(矩形),在两个子类中按照不同图形的面积计算公式,实现Shape类中计算面积的方法 ...
- Check failed: top_shape[j] == bottom[i]-shape(j) (1 vs. 2) All inputs must have the same shape, exc
在运行ShuffleNet的过程中碰到了如下报错 : I1018 19:26:19.104892 3548 net.cpp:84] Creating Layer resx13_concat I1018 ...
最新文章
- Skype for Business Server 2015-07-边缘服务器-3-部署
- 算法:枚举法---kotlin
- Linux服务器通过LVM扩展其磁盘空间
- AE After Effect 如何分段渲染
- 为什么每个请求都要有用户名密码呢,那不是每次都要查询一下了,token,表示这个用户已经验证通过了,在token有效期内,只需要判断token是否有效就可以了...
- 菜鸟教程-css学习笔记
- java编写记事本程序出现图形,高手帮忙啊,老师布置了一个作业,要用java编写一个记事本程序...
- ubuntu14.04上网问题
- keras报错ModuleNotFoundError: No module named ‘keras.backend.tensorflow_backend‘;
- php private ,public protected三者的区别
- c语言的适当大小的子集,使用直接分析法编制C语言子集的词法分析程序..doc
- VC++2010下载教程
- Linux在Ubuntu下安装TFTP
- 知识图谱构建(概念,工具,实例调研)
- MySQL学习笔记(二)
- 电脑中病毒所有html文件,文件夹全部变成exe文件该怎么办?电脑中了kiss病毒的两种解决办法...
- 验证OpenVino时,找不到指定模块的解决
- iOS Mac Catalyst
- MySQL5.6建索引时遇到 Specified key was too long; max key length is 767 bytes错误提示解决办法
- The Thirty-fifth Of Word-Day