首页 Paddle框架 帖子详情
paddle预测报错
收藏
快速回复
Paddle框架 问答深度学习模型训练 733 3
paddle预测报错
收藏
快速回复
Paddle框架 问答深度学习模型训练 733 3

D:\conda\python.exe D:/paddleProject/paddle_cc/yc.py
D:\conda\lib\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp, sys, os
Traceback (most recent call last):
File "D:\paddleProject\paddle_cc\yc.py", line 65, in
model.load("D:\\paddleProject\\paddle_cc\\output\\0.pdparams")
File "D:\conda\lib\site-packages\paddle\hapi\model.py", line 1329, in load
raise err
File "D:\conda\lib\site-packages\paddle\hapi\model.py", line 1321, in load
match_res = _check_match(key, param)
File "D:\conda\lib\site-packages\paddle\hapi\model.py", line 1303, in _check_match
raise ValueError(
ValueError: linear.weight receives a shape [528, 128], but the expected shape is [429, 128].

Process finished with exit code 1

 

我把orc的例子修改了一下,图片格式改成了35*70,线性层也改了的,训练完调用模型就出现了这个报错

0
收藏
回复
全部评论(3)
时间顺序
DeepGeGe
#2 回复于2021-12

ValueError: linear.weight receives a shape [528, 128], but the expected shape is [429, 128].

因为你改了输入大小,因此输入数据经过一系列处理之后,中间某一层输出的shape为[528, 128],但是下一层接收的输入shape要求[429, 128]。因此不匹配,从而报错。

神经网络的输入一般要求是固定的,不然经过卷积最后输出的特征纬度会改变,从而导致后面的全连接层接收的输入纬度会改变。因此修改输入大小,必须修改对应全连接层的input_features的值。

0
回复
JavaRoom
#3 回复于2021-12

这句话有问题了:: linear.weight receives a shape [528, 128], but the expected shape is [429, 128].

0
回复
时间女神
#4 回复于2021-12

linear.weight receives a shape [528, 128], but the expected shape is [429, 128].

检查输入数据的大小,最好把中间过程的数据大小打印看一下

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户