混合模型的建议

时间:2020-07-19 21:11:34

标签: python pytorch autoencoder loss-function cnn

我目前正在使用通过PyTorch进行混合的混合模型,我的意思是自动编码器和CNN,这是我的模型:

convnet((fc_encoder):顺序((0):线性(in_features = 9950, out_features = 200,bias = True))(解码器):顺序((0): 线性(in_features = 200,out_features = 9950,bias = True))(con1): Conv1d(1,2,kernel_size =(5,),步幅=(1,))(max1): MaxPool1d(kernel_size = 4,step = 4,padding = 0,dilation = 1, ceil_mode = False)(con2):Conv1d(2,4,kernel_size =(5,),步幅=(1,)) (max2):MaxPool1d(kernel_size = 4,stride = 4,padding = 0,dilation = 1, ceil_mode = False)(l1):线性(in_features = 2480,out_features = 1024, 偏差=正确)(下降):下降(p = 0.5,原位=假)(l2): 线性(in_features = 1024,out_features = 512,bias = True)(l3): 线性(in_features = 512,out_features = 128,bias = True)(l4): 线性(in_features = 128,out_features = 32,bias = True)(l5): 线性(in_features = 32,out_features = 1,bias = True))

我对以下问题有疑问:

  1. 我正在使用一个损失函数来评估我的模型BCELoss。我想知道是否实现了混合模型,是否需要使用2个损失函数?如果仅根据一个损失函数评估模型,会发生什么?
  2. 第二个问题是,如果我要更改学习率,那么ROC曲线有很大差异,为什么会这样? 我可以提供的输入形状的任何说明。

这是我定义模型的课程:

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)
  

预先感谢

0 个答案:

没有答案