Skip to content

Commit

Permalink
Merge pull request #60 from janelia-cellmap/fix_bug_starter_shape
Browse files Browse the repository at this point in the history
bug fix: loading starter weight, layer exist but mismatch shape
  • Loading branch information
mzouink authored Feb 12, 2024
2 parents 62d6278 + 3c2f0fe commit 84436e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dacapo/experiments/starts/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def initialize_weights(self, model):
model_dict = model.state_dict()
common_layers = set(model_dict.keys()) & set(weights.model.keys())
for layer in common_layers:
model_dict[layer] = weights.model[layer]
if model_dict[layer].shape == weights.model[layer].shape:
model_dict[layer] = weights.model[layer]
else:
logger.warning(f"layer {layer} has different shape, not loading")
model.load_state_dict(model_dict)
logger.warning(f"loaded only common layers from weights")

0 comments on commit 84436e8

Please sign in to comment.