Hi! I’ve had the same problem. Loss was just the same.
This is my model:
class Model(nn.Module):
def __init__(self, input_size, hidden_size, output_size, n_layers):
super().__init__()
self.hidden_size = hidden_size
self.n_layers = n_layers
self.lstm = torch.nn.LSTM(input_size=input_size,
hidden_size=hidden_size,
num_layers=n_layers,
dropout=0.3,
batch_first=True)
self.out = nn.Linear(hidden_size, output_size)
self.relu = nn.ReLU()
def forward(self, input_arr, hidden):
output, (hidden_state, cell_state) = self.lstm(input_arr, hidden)
output = self.out(output)
# output = self.relu(output) <-- Here was the problem
return output, (hidden_state, cell_state)
I think, that model with random weights predicts a lot of negative values. But ReLU cut them out. So, MSELoss can’t do a lot with them. Weights aren’t updated.
But when I removed ReLU activation, it was just fine.
P.S. Thanks everybody who contributed in this discussion. It helped me a lot!