Skip to content

Commit 908355e

Browse files
author
Seppo Enarvi
committed
Describe the magic number 7 in a comment
1 parent b5e8877 commit 908355e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/lightning/pytorch/callbacks/weight_averaging.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ def on_save_checkpoint(
289289
else:
290290
average_model_state = self._average_model.state_dict()
291291
checkpoint["current_model_state"] = checkpoint["state_dict"]
292+
# Truncate the "module." prefix (the first 7 characters) from the names of the variables in the
293+
# AveragedModel state.
292294
checkpoint["state_dict"] = {
293295
name[7:]: value for name, value in average_model_state.items() if name.startswith("module.")
294296
}

0 commit comments

Comments
 (0)