fan = _calculate_correct_fan(tensor, mode)
gain = calculate_gain(nonlinearity, a)
std = gain / math.sqrt(fan)
with torch.no_grad():
return tensor.normal_(0, std)
Since the function accepts a TENSOR I expect not to use .DATA and using it should throw a runtime error. But surprisingly no error comes. Hence I am confused which one to use (especially for v1.3.1)?
Don’t use the .data attribute as it might yield unwanted side effects.
While you will be able to manipulate the underlying data without raising an error, Autograd won’t be able to track these operations and you might run into a variety of issues later (we had quite a few of these issues already here in the forum ).
This attribute is also removed step by step as seen in this PR by @albanD.