I’m unable to understand why torch.ones(2,2) + True
element-wise adds +1
to all the values?
I’d assume it’s casting the boolean to an int, which in the case of True
is 1 and False
is 0. For example,
>>> x = True
>>> int(x) #returns 1
I’m unable to understand why torch.ones(2,2) + True
element-wise adds +1
to all the values?
I’d assume it’s casting the boolean to an int, which in the case of True
is 1 and False
is 0. For example,
>>> x = True
>>> int(x) #returns 1