解决:RuntimeError: Mismatch in shape: grad_output[0] has a shape of torch.Size([1]) and output[0] has a shape of torch.Size([])
解决方法:
找到代码中有无该句
one = torch.FloatTensor([1])
将其替换为
one = torch.tensor(1, dtype=torch.float)
解决:RuntimeError: Mismatch in shape: grad_output[0] has a shape of torch.Size([1]) and output[0] has a shape of torch.Size([])
解决方法:
找到代码中有无该句
one = torch.FloatTensor([1])
将其替换为
one = torch.tensor(1, dtype=torch.float)