The second approach will use uninitialized memory for self.my_layer while an embedding tensor is filled with values from a Gaussian distribution. Maybe you wanted to call self.my_layer.normal_()?
In this case, both approaches would sample values from a Gaussian.
Thanks @ptrblck!
Sorry I forgot to change the variable name. I meant self.my_layer.data.normal_() in the second (I’ve updated the post).
Now as you mention it, is there a difference between self.my_layer.data.normal_() and self.my_layer.normal_()?