I was trying to add trainable variables directly to ModuleList (but that didn’t work)
self.W = Variable(w_init, requires_grad=True) self.mod_list = torch.nn.ModuleList([self.W])
so then I tried to add the parameters to Module list and that didn’t work either.
self.W = torch.nn.Parameter( w_init ) self.mod_list = torch.nn.ModuleList([self.W])
does not work (and note
w_init should NOT be a Variable, seems tensors work). Not sure why it shouldn’t but the following does work:
self.W = torch.nn.Parameter( w_init )
without adding it to the ModuleList. Why? It feels that I am missing some conceptual thing about pytorch if it doesnt work for this. Anyone can clarify to me?