Pytorch MLP总是返回相同的预测结果
我正在使用Pytork实现一个简单的多层感知器。我的输入数据是450维,输出是120维。我已经规范化了我的输入数据。我使用MSE作为损失函数,训练收敛 当我测试模型时,我发现无论输入是什么,输出几乎总是保持不变(对于所有120维)。我尝试过使模型更简单(2个隐藏层)或更复杂(最多7个隐藏层),但这种情况仍然发生 以下是我构建模型的方式:Pytorch MLP总是返回相同的预测结果,pytorch,regression,mlp,Pytorch,Regression,Mlp,我正在使用Pytork实现一个简单的多层感知器。我的输入数据是450维,输出是120维。我已经规范化了我的输入数据。我使用MSE作为损失函数,训练收敛 当我测试模型时,我发现无论输入是什么,输出几乎总是保持不变(对于所有120维)。我尝试过使模型更简单(2个隐藏层)或更复杂(最多7个隐藏层),但这种情况仍然发生 以下是我构建模型的方式: class MLP(torch.nn.Module): def __init__(self, D_in, D_out): super(MLP, self
class MLP(torch.nn.Module):
def __init__(self, D_in, D_out):
super(MLP, self).__init__()
self.linear_1 = torch.nn.Linear(D_in, 1000)
self.linear_2 = torch.nn.Linear(1000, 1500)
self.linear_3 = torch.nn.Linear(1500, 1000)
self.linear_4 = torch.nn.Linear(1000, 750)
self.linear_5 = torch.nn.Linear(750, 500)
self.linear_6 = torch.nn.Linear(500, 250)
self.linear_7 = torch.nn.Linear(250, D_out)
self.sigmoid = torch.nn.Sigmoid()
def forward(self, x):
x = self.sigmoid(self.linear_1(x))
x = self.sigmoid(self.linear_2(x))
x = self.sigmoid(self.linear_3(x))
x = self.sigmoid(self.linear_4(x))
x = self.sigmoid(self.linear_5(x))
x = self.sigmoid(self.linear_6(x))
y_pred = self.linear_7(x)
return y_pred
有人能对此有什么见解吗?提前谢谢 你呢a)包含一段代码:这样人们就可以观察到你到目前为止所做的事情b)使用像sklearn的MLPregreressor这样的实现,并观察其结果,作为比较的是sakeThanks@Mercury!添加代码后,我还将尝试使用sklearn的模型,看看是否可以得到一些结果。