Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bayesflow/experimental/cif/cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
def compute_metrics(self, x: Tensor, conditions: Tensor = None, stage: str = "training") -> dict[str, Tensor]:
base_metrics = super().compute_metrics(x, conditions=conditions, stage=stage)

elbo = self.log_prob(x, conditions=conditions)
elbo = self.log_prob(x, conditions=conditions, training=stage == "training")

Check warning on line 102 in bayesflow/experimental/cif/cif.py

View check run for this annotation

Codecov / codecov/patch

bayesflow/experimental/cif/cif.py#L102

Added line #L102 was not covered by tests

loss = -keras.ops.mean(elbo)

Expand Down
2 changes: 1 addition & 1 deletion bayesflow/networks/coupling_flow/coupling_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def compute_metrics(
) -> dict[str, Tensor]:
base_metrics = super().compute_metrics(x, conditions=conditions, stage=stage)

z, log_density = self(x, conditions=conditions, inverse=False, density=True)
z, log_density = self(x, conditions=conditions, inverse=False, density=True, training=stage == "training")
loss = weighted_mean(-log_density, sample_weight)

return base_metrics | {"loss": loss}
2 changes: 1 addition & 1 deletion bayesflow/networks/point_inference_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def call(
def compute_metrics(
self, x: Tensor, conditions: Tensor = None, sample_weight: Tensor = None, stage: str = "training"
) -> dict[str, Tensor]:
output = self(x, conditions)
output = self(x, conditions, training=stage == "training")

metrics = {}
# calculate negative score as mean over all scores
Expand Down