This repository was archived by the owner on Jul 7, 2023. It is now read-only.
This repository was archived by the owner on Jul 7, 2023. It is now read-only.
Undefined name 'loss' in the creation of 'training_loss_dict' #1002
Closed
Description
Description
Undefined name loss caused by an invalid comprehension in the code:
training_loss_dict = average_sharded_losses([{
"training": l
} for l in loss for loss in sharded_losses.values()])
https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/utils/t2t_model.py#L341-L343
The above code is an invalid comprehension and will fail with a NameError just like
python -c '[{"training": l} for l in loss for loss in "this is a test".split()]'
Environment information
OS: https://github.com/tensorflow/tensor2tensor
$ python -V
# 3.7.0
For bugs: reproduction and error logs
Steps to reproduce:
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
Error logs:
flake8 testing of https://github.com/tensorflow/tensor2tensor
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./tensor2tensor/utils/t2t_model.py:227:22: F821 undefined name 'loss'
} for l in loss for loss in sharded_losses.values()])
^
1 F821 undefined name 'loss'
1
Metadata
Metadata
Assignees
Labels
No labels