Any Idea why is it returning zero

import torch

from torch import nn

from torch import functional as F

class Model(nn.Module):

    def __init__(self):

        super(Model, self).__init__()

        self.conv = [nn.Conv2d(1, 20, 5)]

        self.conv.append(nn.Conv2d(20, 20, 5))

    def forward(self, x):

        x = F.relu(self.conv[0])

        return F.relu(self.conv[1])

p = Model()

len([i for i in p.parameters()])  #====> This is turning out to be zero

I have a problem where I am not sure how many layers I end up with before hand to name them individually, So I am maintaining a list of conv layers then iterating over them in the forward pass to use them. But

model = Model() 

model.parameters()

is turning out to be 0. How to get rid of this problem. Can anyone please explain.

You would have to use nn.ModuleList instead of a Python list to make sure the submodules are properly registered inside the Model.