Probably yes, but you should compare the default arguments to both methods, as each framework might use other defaults.


self.embeddings is not created as an nn.Parameter, so Autograd won’t calculate the gradients for this tensor. You could use:


emb = torch.empty(len(...))
nn.init.xqavier_uniform_(emb)
self.embeddings = nn.Parameter(emb)

instead to create a parameter, which will get gradients.