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,线性层也改了的,训练完调用模型就出现了这个报错
ValueError: linear.weight receives a shape [528, 128], but the expected shape is [429, 128].
因为你改了输入大小,因此输入数据经过一系列处理之后,中间某一层输出的shape为[528, 128],但是下一层接收的输入shape要求[429, 128]。因此不匹配,从而报错。
神经网络的输入一般要求是固定的,不然经过卷积最后输出的特征纬度会改变,从而导致后面的全连接层接收的输入纬度会改变。因此修改输入大小,必须修改对应全连接层的input_features的值。
这句话有问题了:: linear.weight receives a shape [528, 128], but the expected shape is [429, 128].
linear.weight receives a shape [528, 128], but the expected shape is [429, 128].
检查输入数据的大小,最好把中间过程的数据大小打印看一下