Skip to content

Commit 7da2016

Browse files
Merge pull request #111 from daniel-habermann/Development
fix some typos and out-of-sync docstrings
2 parents dcc1dfd + 73051ed commit 7da2016

File tree

10 files changed

+42
-42
lines changed

10 files changed

+42
-42
lines changed

bayesflow/computational_utilities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def posterior_calibration_error(
5151
The random draws from the approximate posteriors over ``num_datasets``
5252
prior_samples : np.ndarray of shape (num_datasets, num_params)
5353
The corresponding ground-truth values sampled from the prior
54-
alpha_resolution : int, optional, default: 100
54+
alpha_resolution : int, optional, default: 20
5555
The number of credibility intervals (CIs) to consider
5656
aggregator_fun : callable or None, optional, default: np.median
5757
The function used to aggregate the marginal calibration errors.
@@ -233,7 +233,7 @@ def mmd_kernel_unbiased(x, y, kernel):
233233
Returns
234234
-------
235235
loss : tf.Tensor of shape (,)
236-
The statistically unbiaserd squared maximum mean discrepancy (MMD) value.
236+
The statistically unbiased squared maximum mean discrepancy (MMD) value.
237237
"""
238238

239239
m, n = x.shape[0], y.shape[0]

bayesflow/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
class DefaultJointConfigurator:
29-
"""Fallback class for a generic configrator for joint posterior and likelihood approximation."""
29+
"""Fallback class for a generic configurator for joint posterior and likelihood approximation."""
3030

3131
def __init__(self, default_float_type=np.float32):
3232
self.posterior_config = DefaultPosteriorConfigurator(default_float_type=default_float_type)

bayesflow/coupling_networks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def _calculate_spline(self, target, spline_params, inverse=False):
313313
target : tf.Tensor of shape (batch_size, ..., dim_2)
314314
The target partition of the input vector to transform.
315315
spline_params : tuple(tf.Tensor,...)
316-
A tuple with tensors corresponding to the learnbale spline features:
316+
A tuple with tensors corresponding to the learnable spline features:
317317
(left_edge, bottom_edge, widths, heights, derivatives)
318318
inverse : bool, optional, default: False
319319
Flag indicating whether to run the block forward or backward.
@@ -516,7 +516,7 @@ def __init__(
516516
for the required entries.
517517
coupling_design : str or callable, optional, default: 'affine'
518518
The type of internal coupling network to use. Must be in ['affine', 'spline'].
519-
In general, spline couplings run slower than affine couplings, but require fewers coupling
519+
In general, spline couplings run slower than affine couplings, but requires fewer coupling
520520
layers. Spline couplings may work best with complex (e.g., multimodal) low-dimensional
521521
problems. The difference will become less and less pronounced as we move to higher dimensions.
522522
permutation : str or None, optional, default: 'fixed'
@@ -581,15 +581,15 @@ def __init__(
581581
self.act_norm = None
582582

583583
def call(self, target_or_z, condition, inverse=False, **kwargs):
584-
"""Performs one pass through a the affine coupling layer (either inverse or forward).
584+
"""Performs one pass through the affine coupling layer (either inverse or forward).
585585
586586
Parameters
587587
----------
588588
target_or_z : tf.Tensor
589-
The estimation quantites of interest or latent representations z ~ p(z), shape (batch_size, ...)
589+
The estimation quantities of interest or latent representations z ~ p(z), shape (batch_size, ...)
590590
condition : tf.Tensor or None
591591
The conditioning data of interest, for instance, x = summary_fun(x), shape (batch_size, ...).
592-
If `condition is None`, then the layer recuces to an unconditional ACL.
592+
If `condition is None`, then the layer reduces to an unconditional ACL.
593593
inverse : bool, optional, default: False
594594
Flag indicating whether to run the block forward or backward.
595595

bayesflow/diagnostics.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def plot_recovery(
8484
The parameter names for nice plot titles. Inferred if None
8585
fig_size : tuple or None, optional, default : None
8686
The figure size passed to the matplotlib constructor. Inferred if None.
87-
label_fontsize : int, optional, default: 14
87+
label_fontsize : int, optional, default: 16
8888
The font size of the y-label text
89-
title_fontsize : int, optional, default: 16
89+
title_fontsize : int, optional, default: 18
9090
The font size of the title text
9191
metric_fontsize : int, optional, default: 16
9292
The font size of the goodness-of-fit metric (if provided)
@@ -114,7 +114,7 @@ def plot_recovery(
114114
Raises
115115
------
116116
ShapeError
117-
If there is a deviation form the expected shapes of ``post_samples`` and ``prior_samples``.
117+
If there is a deviation from the expected shapes of ``post_samples`` and ``prior_samples``.
118118
"""
119119

120120
# Sanity check
@@ -252,12 +252,12 @@ def plot_z_score_contraction(
252252
253253
post_contraction = 1 - (posterior_variance / prior_variance)
254254
255-
In other words, the posterior is a proxy for the reduction in uncertainty gained by
255+
In other words, the posterior contraction is a proxy for the reduction in uncertainty gained by
256256
replacing the prior with the posterior. The ideal posterior contraction tends to 1.
257257
Contraction near zero indicates that the posterior variance is almost identical to
258258
the prior variance for the particular marginal parameter distribution.
259259
260-
Note: Means and variances will be estimated vie their sample-based estimators.
260+
Note: Means and variances will be estimated via their sample-based estimators.
261261
262262
[1] Schad, D. J., Betancourt, M., & Vasishth, S. (2021).
263263
Toward a principled Bayesian workflow in cognitive science.
@@ -275,9 +275,9 @@ def plot_z_score_contraction(
275275
The parameter names for nice plot titles. Inferred if None
276276
fig_size : tuple or None, optional, default : None
277277
The figure size passed to the matplotlib constructor. Inferred if None.
278-
label_fontsize : int, optional, default: 14
278+
label_fontsize : int, optional, default: 16
279279
The font size of the y-label text
280-
title_fontsize : int, optional, default: 16
280+
title_fontsize : int, optional, default: 18
281281
The font size of the title text
282282
tick_fontsize : int, optional, default: 12
283283
The font size of the axis ticklabels
@@ -295,7 +295,7 @@ def plot_z_score_contraction(
295295
Raises
296296
------
297297
ShapeError
298-
If there is a deviation form the expected shapes of ``post_samples`` and ``prior_samples``.
298+
If there is a deviation from the expected shapes of ``post_samples`` and ``prior_samples``.
299299
"""
300300

301301
# Sanity check for shape integrity
@@ -421,7 +421,7 @@ def plot_sbc_ecdf(
421421
The font size of the y-label and y-label texts
422422
legend_fontsize : int, optional, default: 14
423423
The font size of the legend text
424-
title_fontsize : int, optional, default: 16
424+
title_fontsize : int, optional, default: 18
425425
The font size of the title text. Only relevant if `stacked=False`
426426
tick_fontsize : int, optional, default: 12
427427
The font size of the axis ticklabels
@@ -587,11 +587,11 @@ def plot_sbc_histograms(
587587
The figure size passed to the matplotlib constructor. Inferred if None
588588
num_bins : int, optional, default: 10
589589
The number of bins to use for each marginal histogram
590-
binomial_interval : float in (0, 1), optional, default: 0.95
590+
binomial_interval : float in (0, 1), optional, default: 0.99
591591
The width of the confidence interval for the binomial distribution
592-
label_fontsize : int, optional, default: 14
592+
label_fontsize : int, optional, default: 16
593593
The font size of the y-label text
594-
title_fontsize : int, optional, default: 16
594+
title_fontsize : int, optional, default: 18
595595
The font size of the title text
596596
tick_fontsize : int, optional, default: 12
597597
The font size of the axis ticklabels
@@ -1077,7 +1077,7 @@ def plot_calibration_curves(
10771077
The font size of the y-label and y-label texts
10781078
legend_fontsize : int, optional, default: 14
10791079
The font size of the legend text (ECE value)
1080-
title_fontsize : int, optional, default: 16
1080+
title_fontsize : int, optional, default: 18
10811081
The font size of the title text. Only relevant if `stacked=False`
10821082
tick_fontsize : int, optional, default: 12
10831083
The font size of the axis ticklabels
@@ -1296,20 +1296,20 @@ def plot_mmd_hypothesis_test(
12961296
The samples from the MMD sampling distribution under the null hypothesis "the model is well-specified"
12971297
mmd_observed : float
12981298
The observed MMD value
1299-
alpha_level : float
1299+
alpha_level : float, optional, default: 0.05
13001300
The rejection probability (type I error)
1301-
null_color : str or tuple
1301+
null_color : str or tuple, optional, default: (0.16407, 0.020171, 0.577478)
13021302
The color of the H0 sampling distribution
1303-
observed_color : str or tuple
1303+
observed_color : str or tuple, optional, default: "red"
13041304
The color of the observed MMD
1305-
alpha_color : str or tuple
1305+
alpha_color : str or tuple, optional, default: "orange"
13061306
The color of the rejection area
1307-
truncate_vlines_at_kde: bool
1307+
truncate_vlines_at_kde: bool, optional, default: False
13081308
true: cut off the vlines at the kde
13091309
false: continue kde lines across the plot
1310-
xmin : float
1310+
xmin : float, optional, default: None
13111311
The lower x-axis limit
1312-
xmax : float
1312+
xmax : float, optional, default: None
13131313
The upper x-axis limit
13141314
bw_factor : float, optional, default: 1.5
13151315
bandwidth (aka. smoothing parameter) of the kernel density estimate

bayesflow/helper_classes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class EarlyStopper:
162162
def __init__(self, patience=5, tolerance=0.05):
163163
"""
164164
165-
patience : int, optional, default: 4
165+
patience : int, optional, default: 5
166166
How many successive times the tolerance value is reached before triggering
167167
an early stopping recommendation.
168168
tolerance : float, optional, default: 0.05
@@ -769,7 +769,7 @@ def __init__(self, capacity_in_batches=500):
769769
770770
Parameters
771771
----------
772-
capacity_in_batches : int, optional, default: 50
772+
capacity_in_batches : int, optional, default: 500
773773
The capacity of the buffer in batches of simulations. Could potentially grow
774774
very large, so make sure you pick a reasonable number!
775775
"""

bayesflow/helper_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def backprop_step(input_dict, amortizer, optimizer, **kwargs):
165165
Parameters
166166
----------
167167
input_dict : dict
168-
The configured output of the genrative model
168+
The configured output of the generative model
169169
amortizer : tf.keras.Model
170170
The custom amortizer. Needs to implement a compute_loss method.
171171
optimizer : tf.keras.optimizers.Optimizer

bayesflow/helper_networks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _inverse(self, target):
179179

180180

181181
class Orthogonal(tf.keras.Model):
182-
"""Imeplements a learnable orthogonal transformation according to [1]. Can be
182+
"""Implements a learnable orthogonal transformation according to [1]. Can be
183183
used as an alternative to a fixed ``Permutation`` layer.
184184
185185
[1] Kingma, D. P., & Dhariwal, P. (2018). Glow: Generative flow with invertible 1x1
@@ -357,7 +357,7 @@ def call(self, target, inverse=False):
357357
If inverse=False: The transformed input and the corresponding Jacobian of the transformation,
358358
v shape: (batch_size, inp_dim), log_det_J shape: (,)
359359
target : tf.Tensor
360-
If inverse=True: The inversly transformed targets, shape == target.shape
360+
If inverse=True: The inversely transformed targets, shape == target.shape
361361
362362
Notes
363363
-----

bayesflow/inference_networks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def __init__(
119119
Optional data-dependent initialization for the internal ``ActNorm`` layers, as done in [5]. Could be helpful
120120
for deep invertible networks.
121121
use_soft_flow : bool, optional, default: False
122-
Whether to perturb the taregt distribution (i.e., parameters) with small amount of independent
123-
noise, as done in [2]. Could be helpful for degenrate distributions.
122+
Whether to perturb the target distribution (i.e., parameters) with small amount of independent
123+
noise, as done in [2]. Could be helpful for degenerate distributions.
124124
soft_flow_bounds : tuple(float, float), optional, default: (1e-3, 5e-2)
125125
The bounds of the continuous uniform distribution from which the noise scale would be sampled
126126
at each iteration. Only relevant when ``use_soft_flow=True``.
@@ -178,7 +178,7 @@ def call(self, targets, condition, inverse=False, **kwargs):
178178
return self.forward(targets, condition, **kwargs)
179179

180180
def forward(self, targets, condition, **kwargs):
181-
"""Performs a forward pass though the chain."""
181+
"""Performs a forward pass through the chain."""
182182

183183
# Add noise to target if using SoftFlow, use explicitly
184184
# not in call(), since methods are public

bayesflow/sensitivity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def misspecification_experiment(
5353
second_config_dict : dict
5454
Configuration for the second misspecification factor
5555
fields: name (str), values (1D np.ndarray)
56-
error_function : callable, default: bayesflow.computational_utilities.aggregated_rmse
56+
error_function : callable, default: bayesflow.computational_utilities.aggregated_error
5757
A callable that computes an error metric on the approximate posterior samples
5858
n_posterior_samples : int, optional, default: 500
5959
Number of samples from the approximate posterior per data set
60-
n_sim : int, optional, default: 100
60+
n_sim : int, optional, default: 200
6161
Number of simulated data sets per configuration
6262
configurator : callable or None, optional, default: None
6363
An optional configurator for the misspecified simulations.

bayesflow/simulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def __init__(
405405
406406
Examples
407407
--------
408-
Varying number of local factors (e.g., groups, participants) between 1 and 100::
408+
Varying number of local factors (e.g., groups, participants) between 1 and 100:
409409
410410
def draw_hyper():
411411
# Draw location for 2D conditional prior
@@ -529,7 +529,7 @@ def __init__(self, batch_simulator_fun=None, simulator_fun=None, context_generat
529529
vectors and context variables and will pass the latter directly to the function. Power users should attempt to provide
530530
optimized batched simulators.
531531
532-
If a ``simulator_fun`` is provided, the interface will assume thatthe function operates on single parameter vectors and
532+
If a ``simulator_fun`` is provided, the interface will assume that the function operates on single parameter vectors and
533533
context variables and will wrap the simulator internally to allow batched functionality.
534534
535535
Parameters
@@ -815,9 +815,9 @@ def plot_pushforward(
815815
funcs_labels : list of str
816816
A list of labels for the functions in funcs_list.
817817
The default behavior without user input is to call the functions "Aggregator function 1, Aggregator function 2, etc."
818-
batch_size : int
818+
batch_size : int, optional, default: 1000
819819
The number of prior draws to generate (and then create and visualizes simulations from)
820-
show_raw_sims : bool
820+
show_raw_sims : bool, optional, default: True
821821
Flag determining whether or not a plot of 49 raw (i.e. unaggregated) simulations is generated.
822822
Useful for very general data exploration.
823823

0 commit comments

Comments
 (0)