I’m creating a class, details are not so important just the fact that in init there are conv layers and nn.Parameters:
class MyClass(nn.Module):
def __init__(self, args):
super(MyClass, self).__init__()
nc = 100
self.teta0 = nn.Parameter(torch.cuda.FloatTensor(1,nc),requires_grad=True)
self.teta1 = nn.Parameter(torch.cuda.FloatTensor(1,nc),requires_grad=True)
self.teta2 = nn.Parameter(torch.cuda.FloatTensor(1,nc),requires_grad=True)
self.conv = nn.Conv2d(1,3,3)
def forward(self,a,b):
first = self.teta2*(a-self.teta1)
....
return loss
Now I’m instantiating the class and print
self.model= MyClass(args)
print(self.model)
I’m getting:
MyClass (
(conv): Conv2d(1, 3, kernel_size=(3, 3), stride=(1, 1))
)
It’s seems like the class is not consisting of those nn.Parameters.
Just to makes things clear, self.conv is there because I had this problem and I wanted to see if the conv layer can be seen.
Any idea what’s going on, where I’m mistaking and what can lead to such an error?
Thanks!