I run the code below by using Pytorch 0.4.1 and Pytorch 1.0.0 respectively with cuda 10.1.
model = nn.Linear(3,2).cuda()
x = torch.FloatTensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]).cuda()
with torch.no_grad():
model.weight = torch.nn.Parameter(torch.cuda.FloatTensor([[1.0, 2.0, 1.0], [2.0, 3.0, 3.0]]))
model.bias = torch.nn.Parameter(torch.cuda.FloatTensor([1.0, 2.0]))
y = model(x)
print(y)
The problem is that the outputs are different:
tensor([[17., 36.],
[41., 84.]], device='cuda:0') # pytorch 0.4
tensor([[ 9., 19.],
[21., 43.]], device='cuda:0') # pytorch 1.0
It’s quite amazing. Is there anyone can help me to solved it? Thanks.