Skip to content

Commit d333870

Browse files
Test quantities Linear Regression Starter notebook (#544)
* Implementation of log-lik test quantity for SBC in starter notebook * update data-dependent test-quantities example * Small typo fixes in linear regression notebook --------- Co-authored-by: Paul-Christian Bürkner <paul.buerkner@gmail.com>
1 parent f6a1708 commit d333870

File tree

2 files changed

+329
-55
lines changed

2 files changed

+329
-55
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: 325 additions & 53 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)