Skip to content
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

KeyError: 'logits #7

Closed
Aitejiu opened this issue Mar 17, 2024 · 1 comment
Closed

KeyError: 'logits #7

Aitejiu opened this issue Mar 17, 2024 · 1 comment

Comments

@Aitejiu
Copy link
Contributor

Aitejiu commented Mar 17, 2024

Sorry, I met the same problem. It's that when I do a valid_step after starting the training, it returns an error.

Traceback (most recent call last):
  File "ddi_zoo/src/train.py", line 507, in <module>
    cli_main()
  File "ddi_zoo/src/train.py", line 500, in cli_main
    distributed_utils.call_main(cfg, main)
  File "/root/code/R2-DDI/fairseq/distributed/utils.py", line 369, in call_main
    main(cfg, **kwargs)
  File "ddi_zoo/src/train.py", line 172, in main
    valid_losses, should_stop = train(cfg, trainer, task, epoch_itr)
  File "/opt/conda/envs/pytorch/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "ddi_zoo/src/train.py", line 296, in train
    valid_losses, should_stop = validate_and_save(
  File "ddi_zoo/src/train.py", line 383, in validate_and_save
    valid_losses = validate(cfg, trainer, task, epoch_itr, valid_subsets)
  File "ddi_zoo/src/train.py", line 453, in validate
    trainer.valid_step(sample)
  File "/opt/conda/envs/pytorch/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/root/code/R2-DDI/fairseq/trainer.py", line 945, in valid_step
    logits = logging_output['logits']
KeyError: 'logits'

Also I would like to inquire. When I use docker, I git down a fairseq, and after I manipulate that fairseq, my pip environment says that my fairseq points to /root/code/fairseq, but in /root/code/R2-DDI (i.e., our project), there is also a fairseq that when I use python setup.py build_ext --inplace and then I execute the training bash ddi_zoo/scripts/train_trans/run_gcn_feat_int_cons.sh new_build2 0.01 1e-4 256, the error reported in the fairseq is instead calling the class in /root/code/R2-DDI/fairseq. I would like to ask if the target in our project calls /root/code/R2-DDI/fairseq or /root/code/fairseq.

@Aitejiu
Copy link
Contributor Author

Aitejiu commented Mar 17, 2024

I solved the problem by realizing that the logits and labels in lines 945, 936 in the trainer.py file in fairseq are not used, I just commented them out and removed them in the return value.
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant