Hi,
Is there a way to access all weights of a neural network model?
E.g. If we have the following class
import torch
import torch.nn as nn
class mlp_new(nn.Module):
def init(self, n_in, n_hid, n_out):
super(mlp_new, self).init()
self.layers = nn.Sequential(
nn.Linear(n_in, n_hid),
nn.ReLU(),
nn.Linear(n_hid, n_out)
)
def forward(self, x):
    return self.layers(x)

my_mlp = mlp_new(10, 5, 1)
Can I access all weights of my_mlp (e.g. my_mlp.layers.weight - not working)?
Actually I want to update all weights of the model using my own method with a single statement like optimizer.step().
Please note that, I know that weights can be accessed layer-wise ( my_mlp.layers[0].weight, my_mlp.layers[2].weight).
Thanks with best regards.