In torch==1.7.1+cu101, I have two tensors
import torch
a = torch.rand(1,5,10)
b = torch.rand(100,1,10)
and a feed-forward network
import torch.nn as nn
l = nn.Linear(10,10)
I force one row of them to be equal:
a[0,0] = b[80][0].clone()
Then I feed both tensors to l:
r1 = l(a)
r2 = l(b)
Apparently, since a[0,0] is equal to b[80,0], r1[0,0] must be equal to r2[80,0].
But it turns out to be like:
(r1[0,0] == r2[80,0]).all()
>>> False
I've fixed the randomness by:
seed = 42
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = True
Does anyone know why (r1[0,0] == r2[80,0]).all() is False?