I’m trying to do occupancy detection with LSTM based on temperature and humidity data as the image shows.
fake prediction1112×1426 72.8 KB
My problem is that I’m getting around 50% accuracy on both of my training and validation dataset under the training. I have tried with different hyperparameters and normalized the dataset etc but I think that the problem is that I don’t really know if my model is implemented correctly. One batch is for example [1, 400, 2] (batch, timesteps, features).
class RNN(nn.Module):
  def __init__(self, input_size, hidden_layer_size, num_classes):
    super(RNN, self).__init__()
    self.hidden_layer_size = hidden_layer_size
    self.lstm = nn.LSTM(input_size, hidden_layer_size, batch_first=True)                                          
    self.fc = nn.Linear(hidden_layer_size, num_classes)
 
  def forward(self, input_seq):
    h0 = torch.zeros(1, input_seq.size(0), self.hidden_layer_size).to(device)
    c0 = torch.zeros(1, input_seq.size(0), self.hidden_layer_size).to(device)
 
    out, (h_out, _) = self.lstm(input_seq, (h0,c0)) 
    h_out = h_out.view(-1, self.hidden_layer_size)
    out = self.fc(h_out)
    
    return out