This is my class to define the model:
class convnet(nn.Module):
def init(self,num_inputs=9950):
super(convnet,self).init()
self.num_inputs=num_inputs
self.fc_encoder= nn.Sequential(
nn.Linear(num_inputs,200)
)
self.decoder = nn.Sequential(
nn.Linear(200,num_inputs)
)
self.con1=nn.Conv1d(1, 2, 5)
self.max1=nn.MaxPool1d(4)
self.con2=nn.Conv1d(2, 4, 5)
self.max2=nn.MaxPool1d(4)
self.l1=nn.Linear(2480,1024)
self.drop=nn.Dropout(p= 0.5)
self.l2=nn.Linear(1024,512)
self.l3=nn.Linear(512,128)
self.l4=nn.Linear(128,32)
self.l5=nn.Linear(32,1)
def forward(self, x):
x = self.fc_encoder(x)
x = self.decoder(x)
x=x.unsqueeze(1)
x=self.con1(x)
x=self.max1(x)
x=self.con2(x)
x=self.max2(x)
x = x.view(x.size(0), -1)
x=self.l1(x)
x=self.drop(x)
x=self.l2(x)
x=self.l3(x)
x=self.l4(x)
x=self.l5(x)
return torch.sigmoid(x)
m = convnet()
m.to(device)