-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
Text Classification with PyTorch Lightning: 'dict' object has no attribute 'task' #5452
Comments
You could manually cast it to a namespace with argparse.Namespace(**ckpt["hparams"]) But @williamFalcon may have a cleaner solution |
I added it with a very very dirty fix, in GLUETransformer init added this to avoid cast it to Namespace if it was a dict
|
The official way to do this is to call |
@nagyrajmund Hey, but that looks like it does not solve the issue. Even without save_hyperparameters() call, it will save the hparams in the checkpoint and the yaml file. |
Hey-hey, I think you misunderstood me, my proposed fix is to replace this line with |
the conclusion after sharing min exmple is missing |
EDIT: Does not work as intended, please check the other comments
It does work, i think as @Borda mentioned the example is missing that. Among, |
@bhashithe mind share the code or is it this example? transformers/examples/text-classification/run_pl_glue.py |
EDIT: Does not work as intended, please check the other comments |
would you mind sending a PR with your fix @bhashithe ? |
No problem, let me send that now. |
Sorry @Borda that save_hyperparameters() fix does not work @nagyrajmund Small oversight on my part, anyway i have it working by resetting hparams to be a Namespace(). |
Created #6027 with fixes. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi,
after manually resolving the
n_gpu
attribute issue inlightning_base.py
(see #5385), I found another strange behaviour in the Text Classification example.I used PL in version 0.8.1 with the
run_pl.sh
script. Training works, but after reloading the model for evaluation, the following error message is thrown:I did some debugging. So the interesting part is in the constructor:
transformers/examples/text-classification/run_pl_glue.py
Lines 26 to 30 in 306f1a2
For training (first initialization), the
hparams
variable outputs:Notice the type: it is a
Namespace
. After training... and re-loading the model checkpoint,hparams
looks like:It's strange, because it is now a normal dictionary so
hparams.task
is not working 😢@sshleifer could you help with that issue 🤔
The text was updated successfully, but these errors were encountered: