How to implement LSTM in pytorch with 3d input and 1d output

I’m trying to do sequence binary classification with LSTM in pytorch. The input data dimension is (3014, 48, 184) and the output shape is (3014,). The purpose is to do medical prediction, which means there are 3014 patients, each patient has 48 hours data, each hour contains 184 features.

device = torch.device("cuda")
lr = 0.001
n_epochs = 10
input_dim = 184    
hidden_dim = 184
layer_dim = 2
output_dim = 1
batch_size = 64
model = RNN(input_dim, hidden_dim, layer_dim, output_dim, batch_size)
model.to(device)
#print(model)
criterion = nn.BCEWithLogitsLoss()
optimizer = torch.optim.Adam(model.parameters(), lr=lr, weight_decay=1e-5)

print('Start model training')

for epoch in range(1, n_epochs + 1):

    for i, (x_batch, y_batch) in enumerate(trainloader):
        x_batch = x_batch.to(device)
        y_batch = y_batch.to(device)
        optimizer.zero_grad()
        out = model(x_batch)
        loss = criterion(out.squeeze(1), y_batch)
        loss.backward()
        optimizer.step()
        print("Epoch {:2d} | lr {:.5f} | loss {:.5f} ".format(epoch, lr, loss))
def __init__(self, input_dim, hidden_dim, layer_dim, output_dim, batch_size):
    super().__init__()
    self.hidden_dim = hidden_dim
    self.layer_dim = layer_dim
    self.lstm = nn.LSTM(input_dim, hidden_dim, layer_dim,  batch_first=True)
    self.fc = nn.Linear(hidden_dim, output_dim)
    self.batch_size = batch_size
    self.hidden = None

def forward(self, x):
    #initializing the hidden states
    h0 = torch.zeros(self.layer_dim, x.size(0), self.hidden_dim).to(device)
    c0 = torch.zeros(self.layer_dim, x.size(0), self.hidden_dim).to(device)
    output, (hn, cn) = self.lstm(x, (h0, c0))
    output=self.fc(output[:,-1])
    return output```

The loss of every epochs is not decreasing and the loss function seems not working, I'm wondering that maybe I implement the model with wrong way. Hope to solve this problem ASAP. Thank you.

I'm expecting the loss will decrese, and the loss function will work properly. I was using keras to build the model before, and it works, I don't know how to bulid LSTM model in pytorch