How to add a tensor as a parameter of a model, apart from conventional layers?
Let’s see an example:
class ABC(nn.Module):
def __init__():
self.Q = [torch.Tensor(100, 50) for _ in range(5)] // A list of 5 tensors
self.layer = nn.Linear(50, 20)
// Rest of the module is abbreviated
abc = ABC()
opti = optim.Adam(abc.parameters())
How to let opti update all the parameters in ABC (i.e., both self.Q and parameters of self.layer).
Many thanks!