损失函数Loss越来越大

发布时间 2023-11-13 23:25:10作者: 黑逍逍

 代表什么:

  预测值和真实值越来越大,模型效果不好

 

为啥?

# class MLPModel(nn.Module):
#     def __init__(self, input_size):
#         super(MLPModel, self).__init__()
#         self.fc1 = nn.Linear(input_size, 128)
#         self.fc2 = nn.Linear(128, 64)
#         self.fc3 = nn.Linear(64, 2)
#
#     def forward(self, x):
#         x = torch.relu(self.fc1(x))
#         x = torch.relu(self.fc2(x))
#         x = self.fc3(x)
#         x = nn.functional.softmax(x, dim=1)
#         return x

  可能出现梯度爆炸或者梯度消失的问题