pop weights if available #1247

This commit is contained in:
Kohya S
2024-04-21 17:45:29 +09:00
parent 52652cba1a
commit 0540c33aca

View File

@@ -481,7 +481,8 @@ class NetworkTrainer:
if not isinstance(model, type(accelerator.unwrap_model(network))): if not isinstance(model, type(accelerator.unwrap_model(network))):
remove_indices.append(i) remove_indices.append(i)
for i in reversed(remove_indices): for i in reversed(remove_indices):
weights.pop(i) if len(weights) > i:
weights.pop(i)
# print(f"save model hook: {len(weights)} weights will be saved") # print(f"save model hook: {len(weights)} weights will be saved")
def load_model_hook(models, input_dir): def load_model_hook(models, input_dir):