Skip to content

Commit

Permalink
Merge pull request bayesflow-org#164 from han-ol/Development
Browse files Browse the repository at this point in the history
Strict enforcement of inductive bias in quantile estimation
  • Loading branch information
stefanradev93 authored May 10, 2024
2 parents a9831b0 + 9a95866 commit bbbbc95
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bayesflow/helper_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,8 @@ def call(self, inputs):
# Apply exponential activation and cumulate to ensure ordered quantiles
below = tf.exp(below_inputs)
above = tf.exp(above_inputs)
below = anchor_input - tf.cumsum(below_inputs, axis=1)
above = anchor_input + tf.cumsum(above_inputs, axis=1)
below = anchor_input - tf.cumsum(below, axis=1)[:, ::-1, :]
above = anchor_input + tf.cumsum(above, axis=1)

# Concatenate and reshape back
x = tf.concat([below, anchor_input, above], axis=1)
Expand Down
1 change: 0 additions & 1 deletion bayesflow/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def quantile_loss(y_pred, y_true, quantile_levels=[0.05, 0.95]):
tau = tf.constant(quantile_levels, dtype=tf.float32)
n_quantiles = tau.shape[0]

# If requested, reshape to separate n_quantiles from n_params
assert (
y_pred.shape[-2] == n_quantiles
), "Second-to-last dimension of network output should contain quantiles for different quantile levels! The dimension does not match with the specified quantile levels."
Expand Down

0 comments on commit bbbbc95

Please sign in to comment.