RuntimeError mat1 dim 1 must match mat2 dim 0

RuntimeError: mat1 dim 1 must match mat2 dim 0

代码

self.fc1 = nn.Linear(128, 120)
self.fc2 = nn.Linear(120, 84)

假设forward中要依次执行fc1和fc2
fc1的out_features 等于fc2的in_features就不会有错误,这里都是120不会有错误
反之

self.fc1 = nn.Linear(128, 121)
self.fc2 = nn.Linear(120, 84)

则出现让面的错误提示

你可能感兴趣的:(bug,python,pytorch,深度学习)