Issue using ._parameters internal method in pytorch
I'm trying to access model parameters using the internal ._parameters method. When I define the model as below, I get model parameters without any issue
model = nn.Linear(10, 10)
print(model._parameters)

However, when I use this method to get parameters of a model defined as a class, I get an empty OrderedDict().
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.fc = nn.Linear(10, 10)

    def forward(self, x):
        return self.fc(x)

model = MyModel()
print(model._parameters)

Is there a solution to this using ._parameters?
NOTE: I understand that using internal methods are frowned upon.

Each linear layer in the MyModel class is a module, and can be accessed using _modules. So you can access the parameters of your model using:
for module_key in model._modules.keys():
    for param_key in model._modules[module_key]._parameters:

        p = model._modules[module_key]._parameters[param_key]

