in lab1 in week 3 NMT i try convert the code from tensorflow to pytorch
and when i converted i train the model but the model don’t train the loss stay fixed don’t change what the problem?? i use colab
Make sure that you are correctly handling the model’s training mode, errors in the forward or backward pass (like not calling optimizer.zero_grad()
or loss.backward()
properly), using an inappropriate learning rate, or mismatches in data preprocessing between the frameworks.
Hope it helps! Feel free to ask if you need further assistance.
@Mkdad_Nbhan_Mrhij
Since, you are using the Google Colab so make sure you can replicate all the libraries used in Week 3.
No coming to possible error, if your loss is not changing while training your PyTorch model for Neural Machine Translation (NMT), here are the possible reasons and solutions:
- Optimizer Not Updating Weights
Check if you forgot to call optimizer.step(), which updates the model’s weights after backpropagation. Also, follow the steps suggested by the @Alireza_Saei optimizer.zero_grad() # Reset gradients before computing new ones. - Loss Function Issue
Make sure your loss function is appropriate and correctly configured. nn.CrossEntropyLoss - Check Learning Rate & Activation
- Ensure the GPU is enabled (Runtime → Change runtime type → Select GPU).
i did that ,still not learning , this the lab → Google Colab
I don’t have this one to with open(‘/content/dates_dataset.txt’, ‘r’) as file