同样的Python代码,在Windows上运行没有错误,在Linux Centos上运行出行错误。

原因:

两个地方里面的包的版本不一致

需要一个一个检查版本:比如python的版本,torch的版本。

 
    out = F.conv2d(input=x, weight=weights, bias=b, stride=1, padding=1) # out: (1, unit_channel, l, d)
RuntimeError: Expected 4-dimensional input for 4-dimensional weight [256, 2, 3, 3], but got 3-dimensional input of size [2, 200, 300] instead

 

posted @ 2025-10-04 16:23  emanlee  阅读(2)  评论(0)    收藏  举报