RuntimeError: OrderedDict mutated during iteration (while using hook)

Im using hook in my code and after a few iterations i get this error:

File "/home/alireza/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 478, in __call__
    for hook in self._forward_hooks.values():
RuntimeError: OrderedDict mutated during iteration

does anyone know why?

3 Likes

Did you fixed the bug finally? i met the situation too…

1 Like