Cannot find variable through .parameters()

Hi,
I implement a model and it has a Variable. Like this one:

class Test(nn.Module):
    def __init__(self):
        super(Test, self).__init__()
        self.W=Variable(torch.randn(10, 10, 10))
    def forward(self, embs, negation):
        pass
t=Test()

However, when I called t.parameters(), it returns an empty list. I don’t know if it’s correct.

I want it returns a list contains self.W. How can I do that? By a rewritting the parameter function?

Your W here is a Variable but not a Parameter.

Use the nn.Parameter class instead.

That’s cool!
Thanks a lot!