How to feed weights of a module from output of another module?
I dont think I can do:
def __init__(self):
self.h = nn.Linear(...)
def forward(self, x, y):
self.h.weights[:] = x
y = self.h(y)
… because it will give an error about cannot do inplace operation on a leaf node (I think?).
However, I’m guessing that assigning x
to .data
will not result in an error, but will result in the gradients not back-propagating into x
?