Skip to content

Seq2seq Transformer Tutorial best model saving #1506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
micahcarroll opened this issue May 5, 2021 · 1 comment
Closed

Seq2seq Transformer Tutorial best model saving #1506

micahcarroll opened this issue May 5, 2021 · 1 comment
Labels
module: torchtext question Text Issues relating to text tutorials

Comments

@micahcarroll
Copy link

micahcarroll commented May 5, 2021

In this tutorial, it says "Save the model if the validation loss is the best we’ve seen so far.", and then the following code follows (also here).

if val_loss < best_val_loss:
        best_val_loss = val_loss
        best_model = model

However, my understanding is that this kind of checkpointing won't work, as best_model will contain a pointer to the same set of parameters as model (which will be updated). I tried to verify this by checking that next(model.parameters()) and next(best_model.parameters()) are identical, and it seemed like that was the case (although admittedly I did not check that the last model was indeed not the best one).

cc @pytorch/team-text-core @Nayef211

@holly1238 holly1238 added the Text Issues relating to text tutorials label Jul 27, 2021
@Nayef211
Copy link
Contributor

Nayef211 commented Mar 8, 2023

This should have been fixed by #2181

@Nayef211 Nayef211 closed this as completed Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: torchtext question Text Issues relating to text tutorials
Projects
None yet
Development

No branches or pull requests

4 participants