Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit c3dedef

Browse files
soaxelbrookersepassi
authored andcommitted
Fix key deletion during key iteration in Python 3 (#304)
Deletion of dict keys while iterating over said dict is a no-no in Python 3, and RuntimeErrors. This simply consumes the dict key iterator into a list before iterative deletion.
1 parent 6aeb3c1 commit c3dedef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tensor2tensor/utils/model_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,6 @@ def _learning_rate_decay(hparams, num_worker_replicas=1, num_train_steps=1):
482482

483483

484484
def _del_dict_nones(d):
485-
for k in d.keys():
485+
for k in list(d.keys()):
486486
if d[k] is None:
487487
del d[k]

0 commit comments

Comments
 (0)