Closed AhmadM-DL closed 4 years ago
Hi, This error doesn't appear in the python and pytorch versions I used for my experiments. However if you use python3 the following code should work:
# remove top_layer parameters from checkpoint
state_dict = checkpoint['state_dict'].copy()
to_delete = []
for key in state_dict:
if 'top_layer' in key:
to_delete.append(key)
for key in to_delete:
del state_dict[key]
model.load_state_dict(state_dict)
Hello there,
I am having the following error when resuming from a checkpoint.
It turns out one can't pop elements from a dictionary while iterating it - according to the following stack overflow answer.
This happens in the main.py file in checkpoint resuming block.
This is supposed to be solved by iterating over a copy of the state_dict rather than the original one as following:
Please correct me if I am wrong.