I want to create a tensor only containing boolean values. In Matlab that would be
a = false(10,1)
PyTorch: Tensors A PyTorch Tensor is basically the same as a numpy array: it does not know anything about deep learning or computational graphs or gradients, and is just a generic n-dimensional array to be used for arbitrary numeric computation.
Isn't this more economical (albeit longer):
a = torch.zeros(10, dtype=torch.bool)
or, in older versions,
a = torch.zeros(10, dtype=torch.uint8)
(Thanks @drevicko for the pointer to bool.)
Already found it:
a = torch.zeros(10)
b = a.type(torch.ByteTensor)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With