From 5d43376769348a08f4b037ac60b310dd180d2138 Mon Sep 17 00:00:00 2001 From: Valentin Pratz Date: Wed, 26 Feb 2025 19:57:20 +0000 Subject: [PATCH] Fix unused weights warning in coupling flow The projector weights were created even when no residual connections were required, leading to warnings as their gradients were not present, as they had no influence on the loss. Fixes #331 --- bayesflow/networks/mlp/hidden_block.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bayesflow/networks/mlp/hidden_block.py b/bayesflow/networks/mlp/hidden_block.py index b16dbeff..c3559895 100644 --- a/bayesflow/networks/mlp/hidden_block.py +++ b/bayesflow/networks/mlp/hidden_block.py @@ -51,7 +51,7 @@ def call(self, inputs: Tensor, training: bool = False, **kwargs) -> Tensor: def build(self, input_shape): self.dense.build(input_shape) - if input_shape[-1] != self.units: + if input_shape[-1] != self.units and self.residual: self.projector = self.add_weight( shape=(input_shape[-1], self.units), initializer="glorot_uniform", trainable=True, name="projector" )