AttributeError: 'Model' object has no attribute 'parameters'
I am using a modified Resnet18, with my own pooling function at the end of the Resnet.
Here is my code:
resnet = resnet18().cuda() #a modified resnet

class Model():
    def __init__(self, model, pool):
        self.model = model
        self.pool= pool #my own pool class which has trainable layers

    def forward(self, sample):
        output = self.model(sample)
        output = self.pool(output)
        output = F.normalize(output, p=2, dim=1)
        return output

Now, obviously I need to train not only the resnet part, but also the pool part.
But, when I check:
model = Model(model=resnet, pool= pool)
print(list(model.parameters()))

It gives:
AttributeError: 'Model' object has no attribute 'parameters'

Can anyone help?

You need you Model to inherit torch.nn.Module:
class Model(torch.nn.Module):
    def __init__(self, model, pool):
        super(Model, self).__init__()
        ...


