bayesflow 2.0.2__tar.gz → 2.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bayesflow-2.0.2 → bayesflow-2.0.3}/PKG-INFO +57 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/README.md +56 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/__init__.py +3 -9
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/adapter.py +34 -13
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/as_set.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/as_time_series.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/broadcast.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/concatenate.py +35 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/constrain.py +30 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/convert_dtype.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/drop.py +4 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/elementwise_transform.py +4 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/expand_dims.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/filter_transform.py +29 -3
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/keep.py +4 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/log.py +10 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/map_transform.py +34 -13
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/numpy_transform.py +4 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/one_hot.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/rename.py +4 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/scale.py +8 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/serializable_custom_transform.py +3 -4
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/shift.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/split.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/sqrt.py +7 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/standardize.py +8 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/to_array.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/to_dict.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/transform.py +6 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/continuous_approximator.py +40 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/model_comparison_approximator.py +34 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/point_approximator.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/__init__.py +7 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/metrics/__init__.py +1 -0
- bayesflow-2.0.3/bayesflow/diagnostics/metrics/model_misspecification.py +155 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/distributions/diagonal_normal.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/distributions/diagonal_student_t.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/distributions/distribution.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/distributions/mixture.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/cif/cif.py +3 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/cif/conditional_gaussian.py +3 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/continuous_time_consistency_model.py +2 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/free_form_flow/free_form_flow.py +2 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/resnet/dense_resnet.py +2 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/resnet/double_conv.py +2 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/resnet/double_linear.py +2 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/resnet/resnet.py +2 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/links/ordered.py +2 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/links/ordered_quantiles.py +2 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/links/positive_definite.py +2 -3
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/metrics/maximum_mean_discrepancy.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/metrics/root_mean_squard_error.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/consistency_models/consistency_model.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/actnorm.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/coupling_flow.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/couplings/dual_coupling.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/couplings/single_coupling.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/permutations/fixed_permutation.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/permutations/orthogonal.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/permutations/random.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/permutations/swap.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/transforms/affine_transform.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/transforms/spline_transform.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/deep_set/deep_set.py +3 -3
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/deep_set/equivariant_layer.py +6 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/deep_set/invariant_layer.py +5 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/embeddings/fourier_embedding.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/embeddings/recurrent_embedding.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/embeddings/time2vec.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/flow_matching/flow_matching.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/mlp/mlp.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/point_inference_network.py +6 -10
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/residual/residual.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/time_series_network/skip_recurrent.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/time_series_network/time_series_network.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/fusion_transformer.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/isab.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/mab.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/pma.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/sab.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/set_transformer.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/time_series_transformer.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/mean_score.py +2 -3
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/median_score.py +2 -3
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/multivariate_normal_score.py +2 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/normed_difference_score.py +2 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/parametric_distribution_score.py +2 -3
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/quantile_score.py +2 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/scoring_rule.py +7 -14
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/__init__.py +2 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/decorators.py +1 -0
- bayesflow-2.0.3/bayesflow/utils/serialization.py +176 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/wrappers/mamba/mamba.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/wrappers/mamba/mamba_block.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow.egg-info/PKG-INFO +57 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow.egg-info/SOURCES.txt +3 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/pyproject.toml +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_adapters/conftest.py +40 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_adapters/test_adapters.py +60 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_approximators/conftest.py +31 -0
- bayesflow-2.0.3/tests/test_approximators/test_summaries.py +23 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_diagnostics/conftest.py +14 -0
- bayesflow-2.0.3/tests/test_diagnostics/test_diagnostics_metrics.py +369 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/test_serialize_deserialize.py +2 -2
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_workflows/conftest.py +1 -1
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/utils/__init__.py +1 -0
- bayesflow-2.0.3/tests/utils/networks.py +8 -0
- bayesflow-2.0.2/bayesflow/utils/serialization.py +0 -141
- bayesflow-2.0.2/tests/test_diagnostics/test_diagnostics_metrics.py +0 -81
- {bayesflow-2.0.2 → bayesflow-2.0.3}/LICENSE +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/adapters/transforms/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/approximator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/backend_approximators/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/backend_approximators/backend_approximator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/backend_approximators/jax_approximator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/backend_approximators/numpy_approximator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/backend_approximators/tensorflow_approximator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/approximators/backend_approximators/torch_approximator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/datasets/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/datasets/disk_dataset.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/datasets/offline_dataset.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/datasets/online_dataset.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/datasets/rounds_dataset.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/metrics/calibration_error.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/metrics/classifier_two_sample_test.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/metrics/expected_calibration_error.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/metrics/posterior_contraction.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/metrics/root_mean_squared_error.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/calibration_ecdf.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/calibration_ecdf_from_quantiles.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/calibration_histogram.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/loss.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/mc_calibration.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/mc_confusion_matrix.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/mmd_hypothesis_test.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/pairs_posterior.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/pairs_samples.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/recovery.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/recovery_from_estimates.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/diagnostics/plots/z_score_contraction.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/distributions/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/cif/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/free_form_flow/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/experimental/resnet/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/links/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/metrics/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/metrics/functional/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/metrics/functional/kernels.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/metrics/functional/maximum_mean_discrepancy.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/metrics/functional/root_mean_squared_error.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/consistency_models/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/couplings/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/invertible_layer.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/permutations/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/transforms/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/transforms/_rational_quadratic.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/coupling_flow/transforms/transform.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/deep_set/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/embeddings/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/flow_matching/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/inference_network.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/mlp/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/residual/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/summary_network.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/time_series_network/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/networks/transformers/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/scores/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/benchmark_simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/bernoulli_glm.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/bernoulli_glm_raw.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/gaussian_linear.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/gaussian_linear_uniform.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/gaussian_mixture.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/inverse_kinematics.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/lotka_volterra.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/sir.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/slcp.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/slcp_distractors.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/benchmark_simulators/two_moons.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/hierarchical_simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/lambda_simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/make_simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/model_comparison_simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/sequential_simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/simulators/simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/types/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/types/shape.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/types/tensor.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/_docs/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/_docs/_populate_all.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/callbacks.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/classification/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/classification/calibration_curve.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/classification/confusion_matrix.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/context_managers.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/devices.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dict_utils.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_cost.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_distribution.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_inference_network.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_network.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_permutation.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_pooling.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_recurrent_net.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/dispatch/find_summary_network.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/ecdf/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/ecdf/minimal_coverage_probs.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/ecdf/pointwise_ecdf_bands.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/ecdf/ranks.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/ecdf/simultaneous_ecdf_bands.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/empty.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/exceptions/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/exceptions/shape_error.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/functional.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/git.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/hparam_utils.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/integrate.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/io.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/jacobian/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/jacobian/jacobian.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/jacobian/jacobian_trace.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/jacobian/jvp.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/jacobian/vjp.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/keras_utils.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/logging.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/numpy_utils.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/optimal_transport/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/optimal_transport/euclidean.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/optimal_transport/log_sinkhorn.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/optimal_transport/optimal_transport.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/optimal_transport/sinkhorn.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/plot_utils.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/tensor_utils.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/utils/validators.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/workflows/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/workflows/basic_workflow.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/workflows/workflow.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/wrappers/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow/wrappers/mamba/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow.egg-info/dependency_links.txt +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow.egg-info/requires.txt +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/bayesflow.egg-info/top_level.txt +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/docsrc/generate-redirects.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/docsrc/poly.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/docsrc/polyversion_patches.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/docsrc/pre-build.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/docsrc/source/conf.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/docsrc/source/sphinxext/adapt_autodoc_docstring.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/docsrc/source/sphinxext/override_pst_pagetoc.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/setup.cfg +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_adapters/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_approximators/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_approximators/test_estimate.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_approximators/test_fit.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_approximators/test_point_approximators/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_approximators/test_point_approximators/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_approximators/test_point_approximators/test_sample.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_datasets/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_datasets/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_datasets/test_datasets.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_diagnostics/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_diagnostics/test_diagnostics_plots.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_distributions/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_distributions/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_distributions/test_distributions.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_examples/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_examples/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_examples/test_examples.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_links/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_links/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_links/test_links.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_coupling_flow/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_coupling_flow/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_coupling_flow/test_invertible_layers.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_coupling_flow/test_permutations.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_embeddings.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_inference_networks.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_mlp/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_mlp/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_mlp/test_mlp.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_point_inference_network/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_point_inference_network/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_point_inference_network/test_point_inference_network.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_networks/test_summary_networks.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_scores/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_scores/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_scores/test_scores.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_simulators/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_simulators/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_simulators/test_simulators.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_two_moons/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_two_moons/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_two_moons/test_two_moons.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/test_dispatch.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/test_ecdf.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/test_integrate.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/test_jacobian.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_utils/test_optimal_transport.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_workflows/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_workflows/test_basic_workflow.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_wrappers/__init__.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_wrappers/conftest.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/test_wrappers/test_mamba.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/utils/assertions.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/utils/callbacks.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/utils/check_combinations.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/utils/jupyter.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/utils/normal_simulator.py +0 -0
- {bayesflow-2.0.2 → bayesflow-2.0.3}/tests/utils/ops.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bayesflow
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.3
|
|
4
4
|
Summary: Amortizing Bayesian Inference With Neural Networks
|
|
5
5
|
Author: The BayesFlow Team
|
|
6
6
|
License: MIT License
|
|
@@ -106,6 +106,25 @@ It provides users and researchers with:
|
|
|
106
106
|
BayesFlow (version 2+) is designed to be a flexible and efficient tool that enables rapid statistical inference
|
|
107
107
|
fueled by continuous progress in generative AI and Bayesian inference.
|
|
108
108
|
|
|
109
|
+
> [!IMPORTANT]
|
|
110
|
+
> As the 2.0 version introduced many new features, we still have to make breaking changes from time to time.
|
|
111
|
+
> This especially concerns **saving and loading** of models. We aim to stabilize this from the 2.1 release onwards.
|
|
112
|
+
> Until then, consider pinning your BayesFlow 2.0 installation to an exact version, or re-training after an update
|
|
113
|
+
> for less costly models.
|
|
114
|
+
|
|
115
|
+
## Important Note for Existing Users
|
|
116
|
+
|
|
117
|
+
You are currently looking at BayesFlow 2.0+, which is a complete rewrite of the library.
|
|
118
|
+
While it shares the same overall goals with the 1.x versions, the API is not compatible.
|
|
119
|
+
|
|
120
|
+
> [!CAUTION]
|
|
121
|
+
> A few features, most notably hierarchical models, have not been ported to BayesFlow 2.0+
|
|
122
|
+
> yet. We are working on those features and plan to add them soon. You can find the complete
|
|
123
|
+
> list in the [FAQ](#faq) below.
|
|
124
|
+
|
|
125
|
+
The [Moving from BayesFlow v1.1 to v2.0](examples/From_BayesFlow_1.1_to_2.0.ipynb) guide
|
|
126
|
+
highlights how concepts and classes relate between the two versions.
|
|
127
|
+
|
|
109
128
|
## Conceptual Overview
|
|
110
129
|
|
|
111
130
|
<div align="center">
|
|
@@ -307,11 +326,48 @@ while the old version was based on TensorFlow.
|
|
|
307
326
|
|
|
308
327
|
-------------
|
|
309
328
|
|
|
329
|
+
**Question:**
|
|
330
|
+
Should I switch to BayesFlow 2.0+ now? Are there features that are still missing?
|
|
331
|
+
|
|
332
|
+
**Answer:**
|
|
333
|
+
In general, we recommend to switch, as the new version is easier to use and will continue
|
|
334
|
+
to receive improvements and new features. However, a few features are still missing, so you
|
|
335
|
+
might want to wait until everything you need has been ported to BayesFlow 2.0+.
|
|
336
|
+
|
|
337
|
+
Depending on your needs, you might not want to upgrade yet if one of the following applies:
|
|
338
|
+
|
|
339
|
+
- You have an ongoing project that uses BayesFlow 1.x, and you do not want to allocate
|
|
340
|
+
time for migrating it to the new API.
|
|
341
|
+
- You have already trained models in BayesFlow 1.x, that you do not want to re-train
|
|
342
|
+
with the new version. Loading models from version 1.x in version 2.0+ is not supported.
|
|
343
|
+
- You require a feature that was not ported to BayesFlow 2.0+ yet. To our knowledge,
|
|
344
|
+
this applies to:
|
|
345
|
+
* Two-level/Hierarchical models (planned for version 2.1): `TwoLevelGenerativeModel`, `TwoLevelPrior`.
|
|
346
|
+
* Sensitivity analysis (partially discontinued): functionality from the `bayesflow.sensitivity` module. This is still
|
|
347
|
+
possible, but we do no longer offer a special module for it. We plan to add a tutorial on this, see [#455](https://github.com/bayesflow-org/bayesflow/issues/455).
|
|
348
|
+
* MCMC (discontinued): The `bayesflow.mcmc` module. We are considering other options
|
|
349
|
+
to enable the use of BayesFlow in an MCMC setting.
|
|
350
|
+
* Networks: `EvidentialNetwork`.
|
|
351
|
+
* Model misspecification detection: MMD test in the summary space (see #384).
|
|
352
|
+
|
|
353
|
+
If you encounter any functionality that is missing and not listed here, please let us
|
|
354
|
+
know by opening an issue.
|
|
355
|
+
|
|
356
|
+
-------------
|
|
357
|
+
|
|
310
358
|
**Question:**
|
|
311
359
|
I still need the old BayesFlow for some of my projects. How can I install it?
|
|
312
360
|
|
|
313
361
|
**Answer:**
|
|
314
362
|
You can find and install the old Bayesflow version via the `stable-legacy` branch on GitHub.
|
|
363
|
+
The corresponding [documentation](https://bayesflow.org/stable-legacy/index.html) can be
|
|
364
|
+
accessed by selecting the "stable-legacy" entry in the version picker of the documentation.
|
|
365
|
+
|
|
366
|
+
You can also install the latest version of BayesFlow v1.x from PyPI using
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
pip install "bayesflow<2.0"
|
|
370
|
+
```
|
|
315
371
|
|
|
316
372
|
-------------
|
|
317
373
|
|
|
@@ -15,6 +15,25 @@ It provides users and researchers with:
|
|
|
15
15
|
BayesFlow (version 2+) is designed to be a flexible and efficient tool that enables rapid statistical inference
|
|
16
16
|
fueled by continuous progress in generative AI and Bayesian inference.
|
|
17
17
|
|
|
18
|
+
> [!IMPORTANT]
|
|
19
|
+
> As the 2.0 version introduced many new features, we still have to make breaking changes from time to time.
|
|
20
|
+
> This especially concerns **saving and loading** of models. We aim to stabilize this from the 2.1 release onwards.
|
|
21
|
+
> Until then, consider pinning your BayesFlow 2.0 installation to an exact version, or re-training after an update
|
|
22
|
+
> for less costly models.
|
|
23
|
+
|
|
24
|
+
## Important Note for Existing Users
|
|
25
|
+
|
|
26
|
+
You are currently looking at BayesFlow 2.0+, which is a complete rewrite of the library.
|
|
27
|
+
While it shares the same overall goals with the 1.x versions, the API is not compatible.
|
|
28
|
+
|
|
29
|
+
> [!CAUTION]
|
|
30
|
+
> A few features, most notably hierarchical models, have not been ported to BayesFlow 2.0+
|
|
31
|
+
> yet. We are working on those features and plan to add them soon. You can find the complete
|
|
32
|
+
> list in the [FAQ](#faq) below.
|
|
33
|
+
|
|
34
|
+
The [Moving from BayesFlow v1.1 to v2.0](examples/From_BayesFlow_1.1_to_2.0.ipynb) guide
|
|
35
|
+
highlights how concepts and classes relate between the two versions.
|
|
36
|
+
|
|
18
37
|
## Conceptual Overview
|
|
19
38
|
|
|
20
39
|
<div align="center">
|
|
@@ -216,11 +235,48 @@ while the old version was based on TensorFlow.
|
|
|
216
235
|
|
|
217
236
|
-------------
|
|
218
237
|
|
|
238
|
+
**Question:**
|
|
239
|
+
Should I switch to BayesFlow 2.0+ now? Are there features that are still missing?
|
|
240
|
+
|
|
241
|
+
**Answer:**
|
|
242
|
+
In general, we recommend to switch, as the new version is easier to use and will continue
|
|
243
|
+
to receive improvements and new features. However, a few features are still missing, so you
|
|
244
|
+
might want to wait until everything you need has been ported to BayesFlow 2.0+.
|
|
245
|
+
|
|
246
|
+
Depending on your needs, you might not want to upgrade yet if one of the following applies:
|
|
247
|
+
|
|
248
|
+
- You have an ongoing project that uses BayesFlow 1.x, and you do not want to allocate
|
|
249
|
+
time for migrating it to the new API.
|
|
250
|
+
- You have already trained models in BayesFlow 1.x, that you do not want to re-train
|
|
251
|
+
with the new version. Loading models from version 1.x in version 2.0+ is not supported.
|
|
252
|
+
- You require a feature that was not ported to BayesFlow 2.0+ yet. To our knowledge,
|
|
253
|
+
this applies to:
|
|
254
|
+
* Two-level/Hierarchical models (planned for version 2.1): `TwoLevelGenerativeModel`, `TwoLevelPrior`.
|
|
255
|
+
* Sensitivity analysis (partially discontinued): functionality from the `bayesflow.sensitivity` module. This is still
|
|
256
|
+
possible, but we do no longer offer a special module for it. We plan to add a tutorial on this, see [#455](https://github.com/bayesflow-org/bayesflow/issues/455).
|
|
257
|
+
* MCMC (discontinued): The `bayesflow.mcmc` module. We are considering other options
|
|
258
|
+
to enable the use of BayesFlow in an MCMC setting.
|
|
259
|
+
* Networks: `EvidentialNetwork`.
|
|
260
|
+
* Model misspecification detection: MMD test in the summary space (see #384).
|
|
261
|
+
|
|
262
|
+
If you encounter any functionality that is missing and not listed here, please let us
|
|
263
|
+
know by opening an issue.
|
|
264
|
+
|
|
265
|
+
-------------
|
|
266
|
+
|
|
219
267
|
**Question:**
|
|
220
268
|
I still need the old BayesFlow for some of my projects. How can I install it?
|
|
221
269
|
|
|
222
270
|
**Answer:**
|
|
223
271
|
You can find and install the old Bayesflow version via the `stable-legacy` branch on GitHub.
|
|
272
|
+
The corresponding [documentation](https://bayesflow.org/stable-legacy/index.html) can be
|
|
273
|
+
accessed by selecting the "stable-legacy" entry in the version picker of the documentation.
|
|
274
|
+
|
|
275
|
+
You can also install the latest version of BayesFlow v1.x from PyPI using
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
pip install "bayesflow<2.0"
|
|
279
|
+
```
|
|
224
280
|
|
|
225
281
|
-------------
|
|
226
282
|
|
|
@@ -50,17 +50,11 @@ def setup():
|
|
|
50
50
|
"in contexts where you need gradients (e.g. custom training loops)."
|
|
51
51
|
)
|
|
52
52
|
|
|
53
|
+
# dynamically add __version__ attribute
|
|
54
|
+
from importlib.metadata import version
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
try:
|
|
56
|
-
from importlib.metadata import version, PackageNotFoundError
|
|
56
|
+
globals()["__version__"] = version("bayesflow")
|
|
57
57
|
|
|
58
|
-
__version__ = version(__name__)
|
|
59
|
-
except PackageNotFoundError:
|
|
60
|
-
__version__ = "2.0.0"
|
|
61
|
-
finally:
|
|
62
|
-
del version
|
|
63
|
-
del PackageNotFoundError
|
|
64
58
|
|
|
65
59
|
# call and clean up namespace
|
|
66
60
|
setup()
|
|
@@ -29,7 +29,7 @@ from .transforms import (
|
|
|
29
29
|
from .transforms.filter_transform import Predicate
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@serializable
|
|
32
|
+
@serializable("bayesflow.adapters")
|
|
33
33
|
class Adapter(MutableSequence[Transform]):
|
|
34
34
|
"""
|
|
35
35
|
Defines an adapter to apply various transforms to data.
|
|
@@ -79,7 +79,9 @@ class Adapter(MutableSequence[Transform]):
|
|
|
79
79
|
|
|
80
80
|
return serialize(config)
|
|
81
81
|
|
|
82
|
-
def forward(
|
|
82
|
+
def forward(
|
|
83
|
+
self, data: dict[str, any], *, stage: str = "inference", log_det_jac: bool = False, **kwargs
|
|
84
|
+
) -> dict[str, np.ndarray] | tuple[dict[str, np.ndarray], dict[str, np.ndarray]]:
|
|
83
85
|
"""Apply the transforms in the forward direction.
|
|
84
86
|
|
|
85
87
|
Parameters
|
|
@@ -88,22 +90,33 @@ class Adapter(MutableSequence[Transform]):
|
|
|
88
90
|
The data to be transformed.
|
|
89
91
|
stage : str, one of ["training", "validation", "inference"]
|
|
90
92
|
The stage the function is called in.
|
|
93
|
+
log_det_jac: bool, optional
|
|
94
|
+
Whether to return the log determinant of the Jacobian of the transforms.
|
|
91
95
|
**kwargs : dict
|
|
92
96
|
Additional keyword arguments passed to each transform.
|
|
93
97
|
|
|
94
98
|
Returns
|
|
95
99
|
-------
|
|
96
|
-
dict
|
|
97
|
-
The transformed data.
|
|
100
|
+
dict | tuple[dict, dict]
|
|
101
|
+
The transformed data or tuple of transformed data and log determinant of the Jacobian.
|
|
98
102
|
"""
|
|
99
103
|
data = data.copy()
|
|
104
|
+
if not log_det_jac:
|
|
105
|
+
for transform in self.transforms:
|
|
106
|
+
data = transform(data, stage=stage, **kwargs)
|
|
107
|
+
return data
|
|
100
108
|
|
|
109
|
+
log_det_jac = {}
|
|
101
110
|
for transform in self.transforms:
|
|
102
|
-
|
|
111
|
+
transformed_data = transform(data, stage=stage, **kwargs)
|
|
112
|
+
log_det_jac = transform.log_det_jac(data, log_det_jac, **kwargs)
|
|
113
|
+
data = transformed_data
|
|
103
114
|
|
|
104
|
-
return data
|
|
115
|
+
return data, log_det_jac
|
|
105
116
|
|
|
106
|
-
def inverse(
|
|
117
|
+
def inverse(
|
|
118
|
+
self, data: dict[str, np.ndarray], *, stage: str = "inference", log_det_jac: bool = False, **kwargs
|
|
119
|
+
) -> dict[str, np.ndarray] | tuple[dict[str, np.ndarray], dict[str, np.ndarray]]:
|
|
107
120
|
"""Apply the transforms in the inverse direction.
|
|
108
121
|
|
|
109
122
|
Parameters
|
|
@@ -112,24 +125,32 @@ class Adapter(MutableSequence[Transform]):
|
|
|
112
125
|
The data to be transformed.
|
|
113
126
|
stage : str, one of ["training", "validation", "inference"]
|
|
114
127
|
The stage the function is called in.
|
|
128
|
+
log_det_jac: bool, optional
|
|
129
|
+
Whether to return the log determinant of the Jacobian of the transforms.
|
|
115
130
|
**kwargs : dict
|
|
116
131
|
Additional keyword arguments passed to each transform.
|
|
117
132
|
|
|
118
133
|
Returns
|
|
119
134
|
-------
|
|
120
|
-
dict
|
|
121
|
-
The transformed data.
|
|
135
|
+
dict | tuple[dict, dict]
|
|
136
|
+
The transformed data or tuple of transformed data and log determinant of the Jacobian.
|
|
122
137
|
"""
|
|
123
138
|
data = data.copy()
|
|
139
|
+
if not log_det_jac:
|
|
140
|
+
for transform in reversed(self.transforms):
|
|
141
|
+
data = transform(data, stage=stage, inverse=True, **kwargs)
|
|
142
|
+
return data
|
|
124
143
|
|
|
144
|
+
log_det_jac = {}
|
|
125
145
|
for transform in reversed(self.transforms):
|
|
126
146
|
data = transform(data, stage=stage, inverse=True, **kwargs)
|
|
147
|
+
log_det_jac = transform.log_det_jac(data, log_det_jac, inverse=True, **kwargs)
|
|
127
148
|
|
|
128
|
-
return data
|
|
149
|
+
return data, log_det_jac
|
|
129
150
|
|
|
130
151
|
def __call__(
|
|
131
152
|
self, data: Mapping[str, any], *, inverse: bool = False, stage="inference", **kwargs
|
|
132
|
-
) -> dict[str, np.ndarray]:
|
|
153
|
+
) -> dict[str, np.ndarray] | tuple[dict[str, np.ndarray], dict[str, np.ndarray]]:
|
|
133
154
|
"""Apply the transforms in the given direction.
|
|
134
155
|
|
|
135
156
|
Parameters
|
|
@@ -145,8 +166,8 @@ class Adapter(MutableSequence[Transform]):
|
|
|
145
166
|
|
|
146
167
|
Returns
|
|
147
168
|
-------
|
|
148
|
-
dict
|
|
149
|
-
The transformed data.
|
|
169
|
+
dict | tuple[dict, dict]
|
|
170
|
+
The transformed data or tuple of transformed data and log determinant of the Jacobian.
|
|
150
171
|
"""
|
|
151
172
|
if inverse:
|
|
152
173
|
return self.inverse(data, stage=stage, **kwargs)
|
|
@@ -5,7 +5,7 @@ from bayesflow.utils.serialization import serializable
|
|
|
5
5
|
from .elementwise_transform import ElementwiseTransform
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@serializable
|
|
8
|
+
@serializable("bayesflow.adapters")
|
|
9
9
|
class AsSet(ElementwiseTransform):
|
|
10
10
|
"""The `.as_set(["x", "y"])` transform indicates that both `x` and `y` are treated as sets.
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ from bayesflow.utils.serialization import serializable
|
|
|
5
5
|
from .elementwise_transform import ElementwiseTransform
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@serializable
|
|
8
|
+
@serializable("bayesflow.adapters")
|
|
9
9
|
class AsTimeSeries(ElementwiseTransform):
|
|
10
10
|
"""The `.as_time_series` transform can be used to indicate that variables shall be treated as time series.
|
|
11
11
|
|
|
@@ -6,7 +6,7 @@ from bayesflow.utils.serialization import serialize, serializable
|
|
|
6
6
|
from .transform import Transform
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
@serializable
|
|
9
|
+
@serializable("bayesflow.adapters")
|
|
10
10
|
class Broadcast(Transform):
|
|
11
11
|
"""
|
|
12
12
|
Broadcasts arrays or scalars to the shape of a given other array.
|
|
@@ -7,7 +7,7 @@ from bayesflow.utils.serialization import serialize, serializable
|
|
|
7
7
|
from .transform import Transform
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
@serializable
|
|
10
|
+
@serializable("bayesflow.adapters")
|
|
11
11
|
class Concatenate(Transform):
|
|
12
12
|
"""Concatenate multiple arrays into a new key. Used to specify how data variables should be treated by the network.
|
|
13
13
|
|
|
@@ -115,3 +115,37 @@ class Concatenate(Transform):
|
|
|
115
115
|
result += f", axis={self.axis}"
|
|
116
116
|
|
|
117
117
|
return result
|
|
118
|
+
|
|
119
|
+
def log_det_jac(
|
|
120
|
+
self,
|
|
121
|
+
data: dict[str, np.ndarray],
|
|
122
|
+
log_det_jac: dict[str, np.ndarray],
|
|
123
|
+
*,
|
|
124
|
+
strict: bool = False,
|
|
125
|
+
inverse: bool = False,
|
|
126
|
+
**kwargs,
|
|
127
|
+
) -> dict[str, np.ndarray]:
|
|
128
|
+
# copy to avoid side effects
|
|
129
|
+
log_det_jac = log_det_jac.copy()
|
|
130
|
+
|
|
131
|
+
if inverse:
|
|
132
|
+
if log_det_jac.get(self.into) is not None:
|
|
133
|
+
raise ValueError(
|
|
134
|
+
"Cannot obtain an inverse Jacobian of concatenation. "
|
|
135
|
+
"Transform your variables before you concatenate."
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return log_det_jac
|
|
139
|
+
|
|
140
|
+
required_keys = set(self.keys)
|
|
141
|
+
available_keys = set(log_det_jac.keys())
|
|
142
|
+
common_keys = available_keys & required_keys
|
|
143
|
+
|
|
144
|
+
if len(common_keys) == 0:
|
|
145
|
+
return log_det_jac
|
|
146
|
+
|
|
147
|
+
parts = [log_det_jac.pop(key) for key in common_keys]
|
|
148
|
+
|
|
149
|
+
log_det_jac[self.into] = sum(parts)
|
|
150
|
+
|
|
151
|
+
return log_det_jac
|
|
@@ -11,7 +11,7 @@ from bayesflow.utils.numpy_utils import (
|
|
|
11
11
|
from .elementwise_transform import ElementwiseTransform
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
@serializable
|
|
14
|
+
@serializable("bayesflow.adapters")
|
|
15
15
|
class Constrain(ElementwiseTransform):
|
|
16
16
|
"""
|
|
17
17
|
Constrains neural network predictions of a data variable to specified bounds.
|
|
@@ -87,6 +87,11 @@ class Constrain(ElementwiseTransform):
|
|
|
87
87
|
|
|
88
88
|
def unconstrain(x):
|
|
89
89
|
return inverse_sigmoid((x - lower) / (upper - lower))
|
|
90
|
+
|
|
91
|
+
def ldj(x):
|
|
92
|
+
x = (x - lower) / (upper - lower)
|
|
93
|
+
return -np.log(x) - np.log1p(-x) - np.log(upper - lower)
|
|
94
|
+
|
|
90
95
|
case str() as name:
|
|
91
96
|
raise ValueError(f"Unsupported method name for double bounded constraint: '{name}'.")
|
|
92
97
|
case other:
|
|
@@ -101,6 +106,11 @@ class Constrain(ElementwiseTransform):
|
|
|
101
106
|
|
|
102
107
|
def unconstrain(x):
|
|
103
108
|
return inverse_softplus(x - lower)
|
|
109
|
+
|
|
110
|
+
def ldj(x):
|
|
111
|
+
x = x - lower
|
|
112
|
+
return x - np.log(np.exp(x) - 1)
|
|
113
|
+
|
|
104
114
|
case "exp" | "log":
|
|
105
115
|
|
|
106
116
|
def constrain(x):
|
|
@@ -108,6 +118,10 @@ class Constrain(ElementwiseTransform):
|
|
|
108
118
|
|
|
109
119
|
def unconstrain(x):
|
|
110
120
|
return np.log(x - lower)
|
|
121
|
+
|
|
122
|
+
def ldj(x):
|
|
123
|
+
return -np.log(x - lower)
|
|
124
|
+
|
|
111
125
|
case str() as name:
|
|
112
126
|
raise ValueError(f"Unsupported method name for single bounded constraint: '{name}'.")
|
|
113
127
|
case other:
|
|
@@ -122,6 +136,11 @@ class Constrain(ElementwiseTransform):
|
|
|
122
136
|
|
|
123
137
|
def unconstrain(x):
|
|
124
138
|
return -inverse_softplus(-(x - upper))
|
|
139
|
+
|
|
140
|
+
def ldj(x):
|
|
141
|
+
x = -(x - upper)
|
|
142
|
+
return x - np.log(np.exp(x) - 1)
|
|
143
|
+
|
|
125
144
|
case "exp" | "log":
|
|
126
145
|
|
|
127
146
|
def constrain(x):
|
|
@@ -129,6 +148,9 @@ class Constrain(ElementwiseTransform):
|
|
|
129
148
|
|
|
130
149
|
def unconstrain(x):
|
|
131
150
|
return -np.log(-x + upper)
|
|
151
|
+
|
|
152
|
+
def ldj(x):
|
|
153
|
+
return -np.log(-x + upper)
|
|
132
154
|
case str() as name:
|
|
133
155
|
raise ValueError(f"Unsupported method name for single bounded constraint: '{name}'.")
|
|
134
156
|
case other:
|
|
@@ -142,6 +164,7 @@ class Constrain(ElementwiseTransform):
|
|
|
142
164
|
|
|
143
165
|
self.constrain = constrain
|
|
144
166
|
self.unconstrain = unconstrain
|
|
167
|
+
self.ldj = ldj
|
|
145
168
|
|
|
146
169
|
# do this last to avoid serialization issues
|
|
147
170
|
match inclusive:
|
|
@@ -178,3 +201,9 @@ class Constrain(ElementwiseTransform):
|
|
|
178
201
|
def inverse(self, data: np.ndarray, **kwargs) -> np.ndarray:
|
|
179
202
|
# inverse means network space -> data space, so constrain the data
|
|
180
203
|
return self.constrain(data)
|
|
204
|
+
|
|
205
|
+
def log_det_jac(self, data: np.ndarray, inverse: bool = False, **kwargs) -> np.ndarray:
|
|
206
|
+
ldj = self.ldj(data)
|
|
207
|
+
if inverse:
|
|
208
|
+
ldj = -ldj
|
|
209
|
+
return np.sum(ldj, axis=tuple(range(1, ldj.ndim)))
|
|
@@ -5,7 +5,7 @@ from bayesflow.utils.serialization import serializable, serialize
|
|
|
5
5
|
from .elementwise_transform import ElementwiseTransform
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@serializable
|
|
8
|
+
@serializable("bayesflow.adapters")
|
|
9
9
|
class ConvertDType(ElementwiseTransform):
|
|
10
10
|
"""
|
|
11
11
|
Default transform used to convert all floats from float64 to float32 to be in line with keras framework.
|
|
@@ -5,7 +5,7 @@ from bayesflow.utils.serialization import serializable, serialize
|
|
|
5
5
|
from .transform import Transform
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@serializable
|
|
8
|
+
@serializable("bayesflow.adapters")
|
|
9
9
|
class Drop(Transform):
|
|
10
10
|
"""
|
|
11
11
|
Transform to drop variables from further calculation.
|
|
@@ -46,3 +46,6 @@ class Drop(Transform):
|
|
|
46
46
|
|
|
47
47
|
def extra_repr(self) -> str:
|
|
48
48
|
return "[" + ", ".join(map(repr, self.keys)) + "]"
|
|
49
|
+
|
|
50
|
+
def log_det_jac(self, data: dict[str, any], log_det_jac: dict[str, any], inverse: bool = False, **kwargs):
|
|
51
|
+
return self.inverse(data=log_det_jac) if inverse else self.forward(data=log_det_jac)
|
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
|
3
3
|
from bayesflow.utils.serialization import serializable, deserialize
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
@serializable
|
|
6
|
+
@serializable("bayesflow.adapters")
|
|
7
7
|
class ElementwiseTransform:
|
|
8
8
|
"""Base class on which other transforms are based"""
|
|
9
9
|
|
|
@@ -25,3 +25,6 @@ class ElementwiseTransform:
|
|
|
25
25
|
|
|
26
26
|
def inverse(self, data: np.ndarray, **kwargs) -> np.ndarray:
|
|
27
27
|
raise NotImplementedError
|
|
28
|
+
|
|
29
|
+
def log_det_jac(self, data: np.ndarray, inverse: bool = False, **kwargs) -> np.ndarray | None:
|
|
30
|
+
return None
|
|
@@ -14,7 +14,7 @@ class Predicate(Protocol):
|
|
|
14
14
|
raise NotImplementedError
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
@serializable
|
|
17
|
+
@serializable("bayesflow.adapters")
|
|
18
18
|
class FilterTransform(Transform):
|
|
19
19
|
"""
|
|
20
20
|
Implements a transform that applies a different transform on a subset of the data.
|
|
@@ -150,9 +150,35 @@ class FilterTransform(Transform):
|
|
|
150
150
|
return predicate(key, value, inverse=inverse)
|
|
151
151
|
|
|
152
152
|
def _apply_transform(self, key: str, value: np.ndarray, inverse: bool = False, **kwargs) -> np.ndarray:
|
|
153
|
+
transform = self._get_transform(key)
|
|
154
|
+
|
|
155
|
+
return transform(value, inverse=inverse, **kwargs)
|
|
156
|
+
|
|
157
|
+
def _get_transform(self, key: str) -> ElementwiseTransform:
|
|
153
158
|
if key not in self.transform_map:
|
|
154
159
|
self.transform_map[key] = self.transform_constructor(**self.kwargs)
|
|
155
160
|
|
|
156
|
-
|
|
161
|
+
return self.transform_map[key]
|
|
157
162
|
|
|
158
|
-
|
|
163
|
+
def log_det_jac(
|
|
164
|
+
self, data: dict[str, np.ndarray], log_det_jac: dict[str, np.ndarray], *, strict: bool = True, **kwargs
|
|
165
|
+
):
|
|
166
|
+
data = data.copy()
|
|
167
|
+
|
|
168
|
+
if strict and self.include is not None:
|
|
169
|
+
missing_keys = set(self.include) - set(data.keys())
|
|
170
|
+
if missing_keys:
|
|
171
|
+
raise KeyError(f"Missing keys from include list: {missing_keys!r}")
|
|
172
|
+
|
|
173
|
+
for key, value in data.items():
|
|
174
|
+
if self._should_transform(key, value, inverse=False):
|
|
175
|
+
transform = self._get_transform(key)
|
|
176
|
+
ldj = transform.log_det_jac(value, **kwargs)
|
|
177
|
+
if ldj is None:
|
|
178
|
+
continue
|
|
179
|
+
elif key in log_det_jac:
|
|
180
|
+
log_det_jac[key] += ldj
|
|
181
|
+
else:
|
|
182
|
+
log_det_jac[key] = ldj
|
|
183
|
+
|
|
184
|
+
return log_det_jac
|
|
@@ -5,7 +5,7 @@ from bayesflow.utils.serialization import serializable, serialize
|
|
|
5
5
|
from .transform import Transform
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@serializable
|
|
8
|
+
@serializable("bayesflow.adapters")
|
|
9
9
|
class Keep(Transform):
|
|
10
10
|
"""
|
|
11
11
|
Name the data parameters that should be kept for futher calculation.
|
|
@@ -57,3 +57,6 @@ class Keep(Transform):
|
|
|
57
57
|
|
|
58
58
|
def extra_repr(self) -> str:
|
|
59
59
|
return "[" + ", ".join(map(repr, self.keys)) + "]"
|
|
60
|
+
|
|
61
|
+
def log_det_jac(self, data: dict[str, any], log_det_jac: dict[str, any], inverse: bool = False, **kwargs):
|
|
62
|
+
return self.inverse(data=log_det_jac) if inverse else self.forward(data=log_det_jac)
|
|
@@ -5,7 +5,7 @@ from bayesflow.utils.serialization import serializable, serialize
|
|
|
5
5
|
from .elementwise_transform import ElementwiseTransform
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@serializable
|
|
8
|
+
@serializable("bayesflow.adapters")
|
|
9
9
|
class Log(ElementwiseTransform):
|
|
10
10
|
"""Log transforms a variable.
|
|
11
11
|
|
|
@@ -37,3 +37,12 @@ class Log(ElementwiseTransform):
|
|
|
37
37
|
|
|
38
38
|
def get_config(self) -> dict:
|
|
39
39
|
return serialize({"p1": self.p1})
|
|
40
|
+
|
|
41
|
+
def log_det_jac(self, data: np.ndarray, inverse: bool = False, **kwargs) -> np.ndarray:
|
|
42
|
+
if self.p1:
|
|
43
|
+
ldj = -np.log1p(data)
|
|
44
|
+
else:
|
|
45
|
+
ldj = -np.log(data)
|
|
46
|
+
if inverse:
|
|
47
|
+
ldj = -ldj
|
|
48
|
+
return np.sum(ldj, axis=tuple(range(1, ldj.ndim)))
|
|
@@ -6,7 +6,7 @@ from .elementwise_transform import ElementwiseTransform
|
|
|
6
6
|
from .transform import Transform
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
@serializable
|
|
9
|
+
@serializable("bayesflow.adapters")
|
|
10
10
|
class MapTransform(Transform):
|
|
11
11
|
"""
|
|
12
12
|
Implements a transform that applies a set of elementwise transforms
|
|
@@ -41,12 +41,8 @@ class MapTransform(Transform):
|
|
|
41
41
|
def forward(self, data: dict[str, np.ndarray], *, strict: bool = True, **kwargs) -> dict[str, np.ndarray]:
|
|
42
42
|
data = data.copy()
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
missing_keys = required_keys - available_keys
|
|
47
|
-
|
|
48
|
-
if strict and missing_keys:
|
|
49
|
-
raise KeyError(f"Missing keys: {missing_keys!r}")
|
|
44
|
+
if strict:
|
|
45
|
+
self._check_keys(data)
|
|
50
46
|
|
|
51
47
|
for key, transform in self.transform_map.items():
|
|
52
48
|
if key in data:
|
|
@@ -57,15 +53,40 @@ class MapTransform(Transform):
|
|
|
57
53
|
def inverse(self, data: dict[str, np.ndarray], *, strict: bool = False, **kwargs) -> dict[str, np.ndarray]:
|
|
58
54
|
data = data.copy()
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
missing_keys = required_keys - available_keys
|
|
63
|
-
|
|
64
|
-
if strict and missing_keys:
|
|
65
|
-
raise KeyError(f"Missing keys: {missing_keys!r}")
|
|
56
|
+
if strict:
|
|
57
|
+
self._check_keys(data)
|
|
66
58
|
|
|
67
59
|
for key, transform in self.transform_map.items():
|
|
68
60
|
if key in data:
|
|
69
61
|
data[key] = transform.inverse(data[key], **kwargs)
|
|
70
62
|
|
|
71
63
|
return data
|
|
64
|
+
|
|
65
|
+
def log_det_jac(
|
|
66
|
+
self, data: dict[str, np.ndarray], log_det_jac: dict[str, np.ndarray], *, strict: bool = True, **kwargs
|
|
67
|
+
) -> dict[str, np.ndarray]:
|
|
68
|
+
data = data.copy()
|
|
69
|
+
|
|
70
|
+
if strict:
|
|
71
|
+
self._check_keys(data)
|
|
72
|
+
|
|
73
|
+
for key, transform in self.transform_map.items():
|
|
74
|
+
if key in data:
|
|
75
|
+
ldj = transform.log_det_jac(data[key], **kwargs)
|
|
76
|
+
|
|
77
|
+
if ldj is None:
|
|
78
|
+
continue
|
|
79
|
+
elif key in log_det_jac:
|
|
80
|
+
log_det_jac[key] += ldj
|
|
81
|
+
else:
|
|
82
|
+
log_det_jac[key] = ldj
|
|
83
|
+
|
|
84
|
+
return log_det_jac
|
|
85
|
+
|
|
86
|
+
def _check_keys(self, data: dict[str, np.ndarray]):
|
|
87
|
+
required_keys = set(self.transform_map.keys())
|
|
88
|
+
available_keys = set(data.keys())
|
|
89
|
+
missing_keys = required_keys - available_keys
|
|
90
|
+
|
|
91
|
+
if missing_keys:
|
|
92
|
+
raise KeyError(f"Missing keys: {missing_keys!r}")
|
|
@@ -5,7 +5,7 @@ from bayesflow.utils.serialization import serializable, serialize
|
|
|
5
5
|
from .elementwise_transform import ElementwiseTransform
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@serializable
|
|
8
|
+
@serializable("bayesflow.adapters")
|
|
9
9
|
class NumpyTransform(ElementwiseTransform):
|
|
10
10
|
"""
|
|
11
11
|
A class to apply element-wise transformations using plain NumPy functions.
|
|
@@ -72,3 +72,6 @@ class NumpyTransform(ElementwiseTransform):
|
|
|
72
72
|
|
|
73
73
|
def inverse(self, data: np.ndarray, **kwargs) -> np.ndarray:
|
|
74
74
|
return self._inverse(data)
|
|
75
|
+
|
|
76
|
+
def log_det_jac(self, data, inverse=False, **kwargs):
|
|
77
|
+
raise NotImplementedError("log determinant of the Jacobian of the numpy transforms are not implemented yet")
|