pytorch:网络定义参数的时候后面不能加".cuda()" 2022-10-20 11:07:22 pytorch定义网络__init__()的时候,参数不能加“cuda()", 不然参数不包含在state_dict()中,比如下面这种写法是错误的self.W1= nn.Parameter(torch.FloatTensor(3,3), requires_grad=True).cuda()应该去掉".cuda()"self.W1= nn.Parameter(torch.FloatTensor(3,3), requires_grad=True)