Skip to content

Commit d16467b

Browse files
committed
update data-dependent test-quantities example
1 parent 6e64bb6 commit d16467b

File tree

2 files changed

+165
-221
lines changed

2 files changed

+165
-221
lines changed

bayesflow/diagnostics/plots/calibration_ecdf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ def calibration_ecdf(
144144
tq_targets = test_quantity_fn(data=targets)
145145
test_quantities_targets[key] = np.expand_dims(tq_targets, axis=1)
146146

147-
# # Flatten estimates for batch processing in test_quantity_fn, apply function, and restore shape
147+
# Flatten estimates for batch processing in test_quantity_fn, apply function, and restore shape
148148
num_conditions, num_samples = next(iter(estimates.values())).shape[:2]
149-
flattened_estimates = keras.tree.map_structure(lambda t: np.reshape(t, (-1, *t.shape[2:])), estimates)
149+
flattened_estimates = keras.tree.map_structure(
150+
lambda t: np.reshape(t, (num_conditions * num_samples, *t.shape[2:])), estimates
151+
)
150152
flat_tq_estimates = test_quantity_fn(data=flattened_estimates)
151153
test_quantities_estimates[key] = np.reshape(flat_tq_estimates, (num_conditions, num_samples, 1))
152154

examples/Linear_Regression_Starter.ipynb

Lines changed: 161 additions & 219 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)