Assign variable to model parameter - PyTorch Forums
discuss.pytorch.org › t › assign-variable-to-modelAug 12, 2017 · Hello, I have a trained model with some parameters. What I would like to do is to assign to some of those parameters variables that I create, so that I can backpropagate through the variables. Up until now I have done something like for p in model.parameters(): p.data = #whatever But now this won’t work because the backpropagation will not function this way. I need to do something like ...
Parameter — PyTorch 1.10.1 documentation
pytorch.org › torchParameter¶ class torch.nn.parameter. Parameter (data = None, requires_grad = True) [source] ¶. A kind of Tensor that is to be considered a module parameter. Parameters are Tensor subclasses, that have a very special property when used with Module s - when they’re assigned as Module attributes they are automatically added to the list of its parameters, and will appear e.g. in parameters ...