Another newbie question here.
My model’s training loss decreases pretty fast, yet  the performance on the validation data is very poor. It basically takes random guesses. I already increased the amount of training data heavily to avoid overfitting. I am wondering now whether I am doing somethin wrong with the way I save/load the model parameters…I look through some example codes but I don’t find them too useful for beginners.
Some code snippets:
Training and saving the model:
def train_model(learning_rate, epochs): 
    
     dual_encoder.train()
        
     optimizer = torch.optim.Adam(dual_encoder.parameters(), lr = learning_rate)
       
     loss_func = torch.nn.BCEWithLogitsLoss()
     
     for epoch in range(epochs): 
                             
            context_id_list, response_id_list, label_array = load_ids_and_labels(dataframe, word_to_id)
            
            loss_sum = 0.0
                
            for i in range(len(label_array)):
                context = autograd.Variable(torch.LongTensor(context_id_list[i]).view(-1,1), requires_grad = False)
                
                response = autograd.Variable(torch.LongTensor(response_id_list[i]).view(-1, 1), requires_grad = False)
                
                label = autograd.Variable(torch.FloatTensor(torch.from_numpy(np.array(label_array[i]).reshape(1,1))), requires_grad = False)
                
                score = dual_encoder(context, response)
        
                loss = loss_func(score, label)
                
                loss_sum += loss.data[0]
                
                loss.backward()
        
                optimizer.step()
               
                optimizer.zero_grad()
                
                torch.nn.utils.clip_grad_norm(dual_encoder.parameters(), 10)
                
                
            print("Epoch: ", epoch, ", Loss: ", (loss_sum/len(label_array)))
            
            

train_model(learning_rate = 0.001, epochs = 5)

torch.save(dual_encoder.state_dict(), 'SAVED_MODEL.pt')

Loading the model:
encoder_model = model_and_training.Encoder(
        input_size = model_and_training.emb_dim,
        hidden_size = 200,
        vocab_size = model_and_training.vocab_len)

dual_encoder = model_and_training.DualEncoder(encoder_model)

dual_encoder.load_state_dict(torch.load('SAVED_MODEL.pt'))

dual_encoder.eval()