Well, thanks for your reminding.
But when I change the codes, the problem still exists：

RuntimeError                              Traceback (most recent call last)
 in 
25         img_data, target = img_data.to(device), target.to(device)
26
—> 27         output = model(img_data) #FWD prop
28
29         loss = criterion(output, target) #Cross entropy loss
D:\pythonana\envs\pytorch\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
530             result = self._slow_forward(*input, **kwargs)
531         else:
–> 532             result = self.forward(*input, **kwargs)
533         for hook in self._forward_hooks.values():
534             hook_result = hook(self, input, result)
C:\yaqi_anaconda\senet.py in forward(self, x)
102         out = F.avg_pool2d(out, 4)
103         out = out.view(out.size(0), -1)
–> 104         out = self.linear(out)
105         return out
106
D:\pythonana\envs\pytorch\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
530             result = self._slow_forward(*input, **kwargs)
531         else:
–> 532             result = self.forward(*input, **kwargs)
533         for hook in self._forward_hooks.values():
534             hook_result = hook(self, input, result)
D:\pythonana\envs\pytorch\lib\site-packages\torch\nn\modules\linear.py in forward(self, input)
85
86     def forward(self, input):
—> 87         return F.linear(input, self.weight, self.bias)
88
89     def extra_repr(self):
D:\pythonana\envs\pytorch\lib\site-packages\torch\nn\functional.py in linear(input, weight, bias)
1368     if input.dim() == 2 and bias is not None:
1369         # fused op is marginally faster
-> 1370         ret = torch.addmm(bias, input, weight.t())
1371     else:
1372         output = input.matmul(weight.t())
RuntimeError: size mismatch, m1: [8 x 73728], m2: [512 x 10] at C:/w/1/s/windows/pytorch/aten/src\THC/generic/THCTensorMathBlas.cu:290