In torch we can do torch.zeros(3, 4):randn()
for in place randomization of values. This doesn’t seem to work in pytorch. Is this (minor but convenient) feature available in pytorch? (There is in place torch.zeros(3, 4).random_()
but that’s just random floats, it seems)
you can do:
a = torch.zeros(3, 4) # or whatever shape
torch.randn(3, 4, out=a)
But yea we didn’t implement some methods. We just didn’t get around to it.
:randn()
just sampled values from a standard normal distribution, so torch.Tensor(3, 4).normal_()
is equivalent.
FYI, this isn’t implemented yet:
>>> torch.cuda.FloatTensor(3,2).random_()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'torch.cuda.FloatTensor' object has no attribute 'random_'
But, @smth’s suggestion works greatly.