From 3c2f0febf91e2c37a5f49e164667610517cf10fb Mon Sep 17 00:00:00 2001 From: mzouink Date: Mon, 12 Feb 2024 08:00:02 -0500 Subject: [PATCH] bug fix: loading starter weight, layer exist but mismatch shape --- dacapo/experiments/starts/start.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dacapo/experiments/starts/start.py b/dacapo/experiments/starts/start.py index 70f77e316..68dcc0a28 100644 --- a/dacapo/experiments/starts/start.py +++ b/dacapo/experiments/starts/start.py @@ -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")