前向传播没问题,反向传播出现问题解决
RuntimeError: Function MmBackward returned an invalid gradient at index 0 - got [406,32] but expected shape compatible with [406, 132]
1.这个问题是在定义的时候出错
比如代码
self.pro_fc = nn.Linear(32, 128) 这是错误的
改成 self.fc = nn.Linear(132, 128)
着重检查,去搜所一下32定位检查一下!!!
2.要么就是参数不在一个设备上(概率不大)