Is this predicted?
It’s not intuitive, at least for me.
x = torch.normal(0.0, 5, size=(4, 16, 32, 32))
try:
# trial 1
y = torch.where(x > 0, x, 0)
except:
print('trial 1 failed')
else:
print('trial 1 succeed, the size of y: ', y.size())
try:
# trial 2
y = torch.where(x > 0, x, 0.0)
except:
print('trial 2 failed')
else:
print('trial 2 succeed, the size of y: ', y.size())
try:
# trial 3
y = torch.where(x > 0, x, torch.tensor(0.0))
except:
print('trial 3 failed')
else:
print('trial 3 succeed, the size of y: ', y.size())
trial 1 failed
trial 2 failed
trial 3 succeed, the size of y: torch.Size([4, 16, 32, 32])