synference 0.1.0__tar.gz → 0.1.2__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.
Files changed (144) hide show
  1. {synference-0.1.0 → synference-0.1.2}/.github/workflows/docs.yml +5 -4
  2. {synference-0.1.0 → synference-0.1.2}/.github/workflows/python-app.yml +3 -1
  3. {synference-0.1.0 → synference-0.1.2}/.gitignore +4 -3
  4. {synference-0.1.0 → synference-0.1.2}/PKG-INFO +23 -20
  5. {synference-0.1.0 → synference-0.1.2}/README.md +21 -19
  6. {synference-0.1.0 → synference-0.1.2}/docs/CONTRIBUTING.md +1 -1
  7. {synference-0.1.0 → synference-0.1.2}/docs/source/FAQ/FAQ.rst +21 -3
  8. {synference-0.1.0 → synference-0.1.2}/docs/source/advanced_topics/advanced_topics.rst +0 -1
  9. {synference-0.1.0 → synference-0.1.2}/docs/source/advanced_topics/custom_loop.ipynb +125 -6
  10. synference-0.1.2/docs/source/advanced_topics/simformer.ipynb +109 -0
  11. {synference-0.1.0 → synference-0.1.2}/docs/source/conf.py +41 -17
  12. synference-0.1.2/docs/source/getting_started/contributing.rst +171 -0
  13. {synference-0.1.0 → synference-0.1.2}/docs/source/getting_started/installation.rst +9 -1
  14. synference-0.1.2/docs/source/gfx/synference_flow.png +0 -0
  15. synference-0.1.2/docs/source/gfx/synference_logo.png +0 -0
  16. {synference-0.1.0 → synference-0.1.2}/docs/source/index.rst +40 -15
  17. synference-0.1.2/docs/source/library_gen/basic_library_generation.ipynb +523 -0
  18. {synference-0.1.0 → synference-0.1.2}/docs/source/library_gen/bring_your_own_library.ipynb +1 -5
  19. {synference-0.1.0 → synference-0.1.2}/docs/source/library_gen/complex_library_generation.ipynb +35 -181
  20. {synference-0.1.0 → synference-0.1.2}/docs/source/library_gen/library_generation.rst +3 -3
  21. {synference-0.1.0 → synference-0.1.2}/docs/source/library_gen/multithreading_library_generation.ipynb +1 -1
  22. {synference-0.1.0 → synference-0.1.2}/docs/source/library_gen/synthesizer_crash_course.ipynb +51 -89
  23. synference-0.1.2/docs/source/noise_modelling/creating_noise_model.rst +10 -0
  24. {synference-0.1.0 → synference-0.1.2}/docs/source/noise_modelling/noise_models.ipynb +78 -9
  25. synference-0.1.2/docs/source/posterior_inference/catalogue_fitting.ipynb +313 -0
  26. synference-0.1.2/docs/source/posterior_inference/intro.rst +12 -0
  27. synference-0.1.2/docs/source/posterior_inference/sed_recovery.ipynb +172 -0
  28. synference-0.1.2/docs/source/sbi/SBI.ipynb +180 -0
  29. synference-0.1.2/docs/source/sbi/introduction_to_sbi.rst +9 -0
  30. synference-0.1.2/docs/source/sbi_train/basic_sbi_model.ipynb +448 -0
  31. synference-0.1.2/docs/source/sbi_train/complex_sbi_model.ipynb +120 -0
  32. synference-0.1.2/docs/source/sbi_train/feature_array.ipynb +236 -0
  33. synference-0.1.2/docs/source/sbi_train/intro_sbi.rst +15 -0
  34. synference-0.1.2/docs/source/sbi_train/model_optimization.ipynb +104 -0
  35. synference-0.1.2/docs/source/sbi_train/model_validation.ipynb +66 -0
  36. synference-0.1.2/docs/source/sbi_train/online_training.ipynb +129 -0
  37. synference-0.1.2/docs/source/sbi_train/validation_sampling.ipynb +159 -0
  38. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/generate_spectral_library.py +32 -33
  39. {synference-0.1.0 → synference-0.1.2/examples}/paper/bagpipes_comparison.ipynb +260 -4
  40. {synference-0.1.0 → synference-0.1.2/examples}/paper/model_testing.ipynb +4 -17
  41. {synference-0.1.0 → synference-0.1.2/examples}/paper/obs.ipynb +6 -4
  42. synference-0.1.2/examples/sbi/notebooks/train_spectral_model.ipynb +836 -0
  43. synference-0.1.2/examples/sbi/scripts/train_spectral_model.py +326 -0
  44. {synference-0.1.0 → synference-0.1.2}/examples/sbi/slurm/train_final_model.slurm +3 -0
  45. {synference-0.1.0 → synference-0.1.2}/pyproject.toml +7 -2
  46. {synference-0.1.0 → synference-0.1.2}/src/synference/__init__.py +3 -1
  47. {synference-0.1.0 → synference-0.1.2}/src/synference/library.py +149 -85
  48. {synference-0.1.0 → synference-0.1.2}/src/synference/noise_models.py +58 -3
  49. {synference-0.1.0 → synference-0.1.2}/src/synference/sbi_runner.py +155 -7
  50. {synference-0.1.0 → synference-0.1.2}/src/synference/utils.py +26 -1
  51. {synference-0.1.0 → synference-0.1.2}/tests/conftest.py +7 -4
  52. synference-0.1.0/.python-version +0 -1
  53. synference-0.1.0/docs/source/advanced_topics/nle.ipynb +0 -454
  54. synference-0.1.0/docs/source/advanced_topics/simformer.ipynb +0 -187
  55. synference-0.1.0/docs/source/example_libraries/test_model_library.hdf5 +0 -0
  56. synference-0.1.0/docs/source/example_models/bpass_db_v4/BPASS_DenseBasis_v4_final_nsf_0_params.pkl +0 -0
  57. synference-0.1.0/docs/source/example_models/bpass_db_v4/BPASS_DenseBasis_v4_final_nsf_0_params_empirical_noise_models.h5 +0 -0
  58. synference-0.1.0/docs/source/example_models/bpass_db_v4/BPASS_DenseBasis_v4_final_nsf_0_posterior.pkl +0 -0
  59. synference-0.1.0/docs/source/example_models/bpass_db_v4/BPASS_DenseBasis_v4_final_nsf_0_summary.json +0 -1982
  60. synference-0.1.0/docs/source/example_models/bpass_db_v4/grid_BPASS_Chab_DenseBasis_SFH_0.01_z_14_logN_2.7_Calzetti_v3_multinode.hdf5 +0 -0
  61. synference-0.1.0/docs/source/example_models/bpass_db_v4/sbi_test_data_BPASS_DenseBasis_v4_final.npz +0 -0
  62. synference-0.1.0/docs/source/getting_started/contributing.rst +0 -0
  63. synference-0.1.0/docs/source/library_gen/basic_library_generation.ipynb +0 -815
  64. synference-0.1.0/docs/source/noise_modelling/creating_noise_model.rst +0 -10
  65. synference-0.1.0/docs/source/posterior_inference/catalogue_fitting.ipynb +0 -870
  66. synference-0.1.0/docs/source/posterior_inference/intro.rst +0 -9
  67. synference-0.1.0/docs/source/posterior_inference/sed_recovery.ipynb +0 -454
  68. synference-0.1.0/docs/source/posterior_inference/using_your_model.ipynb +0 -136
  69. synference-0.1.0/docs/source/sbi/SBI.ipynb +0 -307
  70. synference-0.1.0/docs/source/sbi/introduction_to_sbi.rst +0 -7
  71. synference-0.1.0/docs/source/sbi_train/basic_sbi_model.ipynb +0 -1465
  72. synference-0.1.0/docs/source/sbi_train/complex_sbi_model.ipynb +0 -326
  73. synference-0.1.0/docs/source/sbi_train/feature_array.ipynb +0 -539
  74. synference-0.1.0/docs/source/sbi_train/intro_sbi.rst +0 -13
  75. synference-0.1.0/docs/source/sbi_train/model_optimization.ipynb +0 -200
  76. synference-0.1.0/docs/source/sbi_train/model_validation.ipynb +0 -45
  77. synference-0.1.0/docs/source/sbi_train/online_training.ipynb +0 -1458
  78. synference-0.1.0/docs/source/sbi_train/validation_sampling.ipynb +0 -273
  79. synference-0.1.0/examples/online/notebooks/active_learning.ipynb +0 -213
  80. synference-0.1.0/examples/sbi/notebooks/empirical_noise_model.ipynb +0 -1013
  81. synference-0.1.0/examples/sbi/notebooks/evidence_networks_model_comparison.ipynb +0 -1030
  82. synference-0.1.0/examples/sbi/notebooks/model_comparison.ipynb +0 -1079
  83. synference-0.1.0/examples/sbi/notebooks/nle.ipynb +0 -18
  84. synference-0.1.0/examples/sbi/notebooks/test_missing_photometry.ipynb +0 -281
  85. synference-0.1.0/examples/sbi/notebooks/train_model_ensemble.ipynb +0 -807
  86. synference-0.1.0/examples/sbi/notebooks/train_spectral_model.ipynb +0 -394
  87. synference-0.1.0/examples/sbi/notebooks/validate_model.ipynb +0 -312
  88. synference-0.1.0/examples/sbi/scripts/train_spectral_model.py +0 -32
  89. synference-0.1.0/examples/simformer/notebooks/integrated_simformer_testing.ipynb +0 -69
  90. synference-0.1.0/examples/simformer/notebooks/model_comparison.ipynb +0 -451
  91. synference-0.1.0/examples/simformer/notebooks/sbi_simformer.ipynb +0 -736
  92. synference-0.1.0/examples/simformer/notebooks/second_test.ipynb +0 -338
  93. synference-0.1.0/examples/simformer/notebooks/simformer_testing.ipynb +0 -671
  94. synference-0.1.0/tests/test_libraries/sbi_test_library.hdf5 +0 -0
  95. synference-0.1.0/tests/test_libraries/sps_test_library.hdf5 +0 -0
  96. {synference-0.1.0 → synference-0.1.2}/.github/workflows/publish_pypi.yml +0 -0
  97. {synference-0.1.0 → synference-0.1.2}/.pre-commit-config.yaml +0 -0
  98. {synference-0.1.0 → synference-0.1.2}/AUTHORS.rst +0 -0
  99. {synference-0.1.0 → synference-0.1.2}/CODE_OF_CONDUCT.md +0 -0
  100. {synference-0.1.0 → synference-0.1.2}/LICENSE.md +0 -0
  101. {synference-0.1.0 → synference-0.1.2}/docs/Makefile +0 -0
  102. {synference-0.1.0 → synference-0.1.2}/docs/make.bat +0 -0
  103. {synference-0.1.0 → synference-0.1.2}/docs/source/API.rst +0 -0
  104. {synference-0.1.0 → synference-0.1.2}/docs/source/getting_started/getting_started.rst +0 -0
  105. {synference-0.1.0 → synference-0.1.2}/docs/source/getting_started/overview.rst +0 -0
  106. {synference-0.1.0 → synference-0.1.2}/docs/source/notebook_examples/cookbook.rst +0 -0
  107. {synference-0.1.0 → synference-0.1.2}/docs/source/templates/custom-class-template.rst +0 -0
  108. {synference-0.1.0 → synference-0.1.2}/docs/source/templates/custom-module-template.rst +0 -0
  109. {synference-0.1.0 → synference-0.1.2}/examples/README.rst +0 -0
  110. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/batch_library_generation.py +0 -0
  111. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/final_library_generation.py +0 -0
  112. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/final_library_generation_multinode.py +0 -0
  113. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/fixed_params.py +0 -0
  114. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/generate_agn_library.py +0 -0
  115. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/generate_library_basic.py +0 -0
  116. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/generate_library_full.py +0 -0
  117. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/generate_pop3_library.py +0 -0
  118. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/grab_filters_for_node.py +0 -0
  119. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/make_library.slurm +0 -0
  120. {synference-0.1.0 → synference-0.1.2}/examples/library_generation/scripts/min_example.py +0 -0
  121. {synference-0.1.0 → synference-0.1.2}/examples/online/notebooks/online_learning.ipynb +0 -0
  122. {synference-0.1.0 → synference-0.1.2}/examples/online/scripts/online_learning.py +0 -0
  123. {synference-0.1.0 → synference-0.1.2/examples}/paper/missing_data.ipynb +0 -0
  124. {synference-0.1.0 → synference-0.1.2/examples}/paper/redshift_inference.ipynb +0 -0
  125. {synference-0.1.0 → synference-0.1.2}/examples/sbi/configs/best_params.yaml +0 -0
  126. {synference-0.1.0 → synference-0.1.2}/examples/sbi/configs/best_params_2101.yaml +0 -0
  127. {synference-0.1.0 → synference-0.1.2}/examples/sbi/configs/custom_loop.yaml +0 -0
  128. {synference-0.1.0 → synference-0.1.2}/examples/sbi/configs/custom_loop_mdn.yaml +0 -0
  129. {synference-0.1.0 → synference-0.1.2}/examples/sbi/configs/custom_loop_test.yaml +0 -0
  130. {synference-0.1.0 → synference-0.1.2}/examples/sbi/notebooks/optimize_sbi.ipynb +0 -0
  131. {synference-0.1.0 → synference-0.1.2}/examples/sbi/scripts/basic_model.py +0 -0
  132. {synference-0.1.0 → synference-0.1.2}/examples/sbi/scripts/train_model.py +0 -0
  133. {synference-0.1.0 → synference-0.1.2}/examples/sbi/scripts/train_sphinx_model.py +0 -0
  134. {synference-0.1.0 → synference-0.1.2}/examples/sbi/scripts/wait_for_gpu.py +0 -0
  135. {synference-0.1.0 → synference-0.1.2}/examples/sbi/slurm/optimize_model.slurm +0 -0
  136. {synference-0.1.0 → synference-0.1.2}/examples/simformer/scripts/fit_simformer_model.py +0 -0
  137. {synference-0.1.0 → synference-0.1.2}/examples/simformer/scripts/model_comparison.py +0 -0
  138. {synference-0.1.0 → synference-0.1.2}/src/synference/custom_runner.py +0 -0
  139. {synference-0.1.0 → synference-0.1.2}/src/synference/py.typed +0 -0
  140. {synference-0.1.0 → synference-0.1.2}/src/synference/simformer.py +0 -0
  141. {synference-0.1.0 → synference-0.1.2}/tests/test_library.py +0 -0
  142. {synference-0.1.0 → synference-0.1.2}/tests/test_sbi.py +0 -0
  143. {synference-0.1.0 → synference-0.1.2}/tests/test_simulator.py +0 -0
  144. {synference-0.1.0 → synference-0.1.2}/tests/test_uncertainty_models.py +0 -0
@@ -42,17 +42,18 @@ jobs:
42
42
  python -m pip install --upgrade pip
43
43
  pip install wheel
44
44
  sudo apt install pandoc
45
+ pip install "cosmos-synthesizer@git+https://github.com/synthesizer-project/synthesizer.git"
45
46
  pip install .[test,docs]
46
- pip install "dense_basis@git+https://github.com/kartheikiyer/dense_basis"
47
+ pip install "dense_basis@git+https://github.com/kartheikiyer/dense_basis.git"
47
48
  pip install "ltu_ili@git+https://github.com/maho3/ltu-ili.git"
49
+ pip install "cosmos-synthesizer@git+https://github.com/synthesizer-project/synthesizer.git#egg=synthesizer"
48
50
  pip install pytest-xdist # enable parallel pytest execution
49
- - name: Download test data
51
+ - name: Download test data
50
52
  run: |
51
53
  # Download test grid data
52
54
  mkdir -p data/libraries/
53
55
  synthesizer-download --test-grids --dust-grid
54
- synference-download --test
55
- cd ../
56
+ python -c "from synference.utils import download_test_data; download_test_data()"
56
57
  - name: Sphinx Build
57
58
  run: |
58
59
  # Test sphinx build (runs all notebooks)
@@ -31,9 +31,11 @@ jobs:
31
31
  - name: Install dependencies
32
32
  run: |
33
33
  python -m pip install --upgrade pip
34
- WITH_OPENMP=1 pip install .
34
+ pip install .
35
35
  pip install ruff pytest
36
36
  pip install "ltu_ili@git+https://github.com/maho3/ltu-ili.git"
37
+ pip install "cosmos-synthesizer@git+https://github.com/synthesizer-project/synthesizer.git#egg=synthesizer"
38
+ python -c "from synference.utils import download_test_data; download_test_data()"
37
39
 
38
40
  - name: Test import
39
41
  run: |
@@ -4,7 +4,6 @@ docs/source/_autosummary
4
4
  docs/source/auto_examples/
5
5
  docs/source/gen_modules/
6
6
  docs/source/sg_execution_times.rst
7
-
8
7
  # Python-generated files
9
8
  __pycache__/
10
9
  *.py[oc]
@@ -50,11 +49,13 @@ uv.lock
50
49
 
51
50
  __marimo__
52
51
  layouts
52
+ docs/source/advanced_topics/config.yaml
53
53
 
54
54
  tests/test_output/*
55
55
  tests/test_grids/*
56
56
  !tests/test_libraries/sbi_test_library.hdf5
57
57
  !tests/test_libraries/sps_test_library.hdf5
58
58
  !docs/build/gfx
59
- !docs/source/example_models/bpass_db_v4/*
60
- !docs/source/example_libraries/*
59
+ !docs/source/example_models/BPASS_DB_v4/*
60
+ !docs/source/example_libraries/*
61
+ !docs/source/gfx/*.png
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synference
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Simulation-based inference for SED-fitting of galaxy photometry and spectroscopy
5
5
  Project-URL: Homepage, https://github.com/synthesizer-project/synference
6
6
  Project-URL: Bug Reports, https://github.com/synthesizer-project/synference/issues
@@ -707,6 +707,7 @@ Requires-Dist: sbi>=0.22.0
707
707
  Requires-Dist: scikit-learn
708
708
  Requires-Dist: scipy
709
709
  Requires-Dist: simple-parsing
710
+ Requires-Dist: tarp
710
711
  Requires-Dist: torch
711
712
  Requires-Dist: tqdm
712
713
  Requires-Dist: unyt
@@ -735,9 +736,7 @@ Requires-Dist: ruff==0.11.7; extra == 'test'
735
736
  Description-Content-Type: text/markdown
736
737
 
737
738
  # Synference
738
- <center>
739
- <img src="docs/source/gfx/synference_logo.png" alt="logo" align="right" width="200px"/>
740
- </center>
739
+ <img src="https://raw.githubusercontent.com/synthesizer-project/synference/main/docs/source/gfx/synference_logo.png" align="right" width="140px"/>
741
740
 
742
741
 
743
742
  [![workflow](https://github.com/synthesizer-project/synference/actions/workflows/python-app.yml/badge.svg)](https://github.com/synthesizer-project/synference/actions)
@@ -745,23 +744,21 @@ Description-Content-Type: text/markdown
745
744
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
746
745
  [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/synthesizer-project/synference/blob/main/docs/CONTRIBUTING.md)
747
746
  [![License: GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
748
-
749
- <!--[![Documentation Status](https://github.com/synthesizer-project/synference/actions/workflows/static.yml/badge.svg)](https://synthesizer-project.github.io/synference/)-->
747
+ [![Documentation Status](https://github.com/synthesizer-project/synference/actions/workflows/docs.yml/badge.svg)](https://synthesizer-project.github.io/synference/)
750
748
 
751
749
  ### Overview
752
750
 
753
- Synference is a Python package designed to fit to perform simulation-based inference (SBI, also known as likelihood free inference) SED fitting. It integrates with [Synthesizer](https://synthesizer-project.github.io) for flexible and fast generation of mock spectra and photometry,
754
- and uses the [LtU-ILI](https://ltu-ili.readthedocs.io/) package for fast, amortised posterior inference.
751
+ Synference is a Python package designed to fit to perform simulation-based inference (SBI, also known as likelihood free inference) SED fitting. It integrates with [Synthesizer](https://synthesizer-project.github.io) for flexible and fast generation of mock spectra and photometry, and uses the [LtU-ILI](https://ltu-ili.readthedocs.io/) package for fast, amortised posterior inference.
755
752
 
756
753
  ### Key Features
757
754
 
758
755
  - **Flexible Mock Generation**: Generate mock spectra and photometry using Synthesizer, allowing for full flexibility in almost every aspect of SED generation, including a wide range of post-processed stellar population synthesis grids.
759
- - **Flexible Training**: Mock photometry creation is seperated from the training of the inference model, allowing for flexible training strategies and the use of different inference models, as well as quickly switching between different feature sets - e.g. different filtersets, different noise models, etc.
756
+ - **Flexible Training**: Mock photometry creation is separated from the training of the inference model, allowing for flexible training strategies and the use of different inference models, as well as quickly switching between different feature sets - e.g. different filtersets, different noise models, etc.
760
757
  - **Fast Inference**: Leverage LtU-ILI for fast, amortised posterior inference, enabling efficient fitting of complex models to data.
761
758
 
762
759
  ### Requirements
763
760
 
764
- synference requires Python 3.10 or higher. It has the following dependencies:
761
+ Synference requires Python 3.10 or higher. It has the following dependencies:
765
762
 
766
763
  - [synthesizer](https://synthesizer-project.github.io) for mock generation
767
764
  - [ltu-ili](https://ltu-ili.readthedocs.io/) for inference
@@ -777,11 +774,17 @@ synference requires Python 3.10 or higher. It has the following dependencies:
777
774
  - [tqdm](https://tqdm.github.io/) for progress bars
778
775
  - [jax](https://jax.readthedocs.io/) for GPU acceleration (optional, for some inference models)
779
776
 
780
- These dependencies will be automatically installed when you install synference using pip.
777
+ These dependencies will be automatically installed when you install Synference using pip.
781
778
 
782
779
  ### Installation
783
780
 
784
- The easiest way to currently install synference is to clone the repository and install it in editable mode:
781
+ The easiest way to currently install Synference is from the PyPI repository.
782
+
783
+ ```bash
784
+ pip install synference
785
+ ```
786
+
787
+ If you want the latest development version you can also clone the repository and install it in editable mode:
785
788
 
786
789
  ```bash
787
790
  git clone https://www.github.com/synthesizer-project/synference.git
@@ -789,9 +792,11 @@ cd synference
789
792
  pip install -e .
790
793
  ```
791
794
 
795
+ Note that due to PyPI restrictions you will have to install [LtU-ILI](https://ltu-ili.readthedocs.io/en/latest/install.html) separately, as it can't be included as a dependency.
796
+
792
797
  ### Getting Started
793
798
 
794
- To get started with synference, you can check out the [examples](examples/) directory for usage examples and tutorials. The examples cover various aspects of using synference, including:
799
+ To get started with Synference, you can check out the [examples](examples/) directory for usage examples and tutorials. The examples cover various aspects of using Synference, including:
795
800
 
796
801
  - Generating mock spectra and photometry with Synthesizer
797
802
  - Training inference models with LtU-ILI
@@ -802,7 +807,7 @@ To get started with synference, you can check out the [examples](examples/) dire
802
807
 
803
808
  The most basic usage, for creating a simple mock catalogue and training a model on it looks like this:
804
809
 
805
- Firstly we setup the Synthesizer based model. More details on how to set up the Synthesizer model can be found in the [Synthesizer documentation](https://synthesizer-project.github.io/). Here we use a BPASS SPS grid, a lognormal star formation history, a single stellar metallicity and a simple emission model including Cloudy nebular emission but no dust reprocessing. The photometric filters used are common JWST/NIRCam wideband filters, but any filters supported by [SVO](https://svo2.cab.inta-csic.es/theory/fps/index.php) or loaded manually can be used. The model parameters are drawn from a Latin hypercube sampling of the parameter space, but this can be done in any way indepedent of synference. All we are providing to the grid generation is a set of *10,000* galaxies with a range of stellar masses, redshifts, metallicities, and star formation histories, and these can be created in any way you like.
810
+ Firstly we setup the Synthesizer based model. More details on how to set up the Synthesizer model can be found in the [Synthesizer documentation](https://synthesizer-project.github.io/). Here we use a BPASS SPS grid, a lognormal star formation history, a single stellar metallicity and a simple emission model including Cloudy nebular emission but no dust reprocessing. The photometric filters used are common JWST/NIRCam wideband filters, but any filters supported by [SVO](https://svo2.cab.inta-csic.es/theory/fps/index.php) or loaded manually can be used. The model parameters are drawn from a Latin hypercube sampling of the parameter space, but this can be done in any way independent of Synference. All we are providing to the grid generation is a set of *10,000* galaxies with a range of stellar masses, redshifts, metallicities, and star formation histories, and these can be created in any way you like.
806
811
 
807
812
  ```python
808
813
  from synthesizer.grid import Grid
@@ -894,17 +899,15 @@ empirical_model_fitter.recover_SED(observed_data_vector)
894
899
 
895
900
  ```
896
901
 
897
- This is just a basic example to get you started. synference is highly flexible and can be adapted to a wide range of use cases in simulation-based inference for SED fitting.
902
+ This is just a basic example to get you started. Synference is highly flexible and can be adapted to a wide range of use cases in simulation-based inference for SED fitting.
898
903
 
899
904
  ### Documentation
900
905
 
901
- Work in progress.
906
+ Documentation for Synference is available at [synthesizer-project.github.io/synference](https://synthesizer-project.github.io/synference/). The documentation includes installation instructions, tutorials, API references, and examples to help you get started with using Synference for your own projects.
902
907
 
903
908
  ### Contributing
904
909
 
905
- We welcome contributions to synference! If you have suggestions, bug reports, or would like to contribute code, please open an issue or submit a pull request on GitHub. Please see our [Code of Conduct](CODE_OF_CONDUCT.md) for more details on how to contribute and interact with the community.
910
+ We welcome contributions to Synference! If you have suggestions, bug reports, or would like to contribute code, please open an issue or submit a pull request on GitHub. Please see our [Code of Conduct](CODE_OF_CONDUCT.md) for more details on how to contribute and interact with the community.
906
911
 
907
912
  ### License
908
- This project is licensed under the GNU General Public License v3.0 (GPLv3). See the [LICENSE](LICENSE) file for details. This means you can use, modify, and distribute the code freely, but any derivative works must also be open source and distributed under the same license. We warn users that this software is offered "as is", without any warranty or guarantee of fitness for a particular purpose. synference is under active development, and therefore may change in the future.
909
-
910
-
913
+ This project is licensed under the GNU General Public License v3.0 (GPLv3). See the [LICENSE](LICENSE) file for details. This means you can use, modify, and distribute the code freely, but any derivative works must also be open source and distributed under the same license. We warn users that this software is offered "as is", without any warranty or guarantee of fitness for a particular purpose. Synference is under active development, and therefore may change in the future.
@@ -1,7 +1,5 @@
1
1
  # Synference
2
- <center>
3
- <img src="docs/source/gfx/synference_logo.png" alt="logo" align="right" width="200px"/>
4
- </center>
2
+ <img src="https://raw.githubusercontent.com/synthesizer-project/synference/main/docs/source/gfx/synference_logo.png" align="right" width="140px"/>
5
3
 
6
4
 
7
5
  [![workflow](https://github.com/synthesizer-project/synference/actions/workflows/python-app.yml/badge.svg)](https://github.com/synthesizer-project/synference/actions)
@@ -9,23 +7,21 @@
9
7
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
10
8
  [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/synthesizer-project/synference/blob/main/docs/CONTRIBUTING.md)
11
9
  [![License: GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
12
-
13
- <!--[![Documentation Status](https://github.com/synthesizer-project/synference/actions/workflows/static.yml/badge.svg)](https://synthesizer-project.github.io/synference/)-->
10
+ [![Documentation Status](https://github.com/synthesizer-project/synference/actions/workflows/docs.yml/badge.svg)](https://synthesizer-project.github.io/synference/)
14
11
 
15
12
  ### Overview
16
13
 
17
- Synference is a Python package designed to fit to perform simulation-based inference (SBI, also known as likelihood free inference) SED fitting. It integrates with [Synthesizer](https://synthesizer-project.github.io) for flexible and fast generation of mock spectra and photometry,
18
- and uses the [LtU-ILI](https://ltu-ili.readthedocs.io/) package for fast, amortised posterior inference.
14
+ Synference is a Python package designed to fit to perform simulation-based inference (SBI, also known as likelihood free inference) SED fitting. It integrates with [Synthesizer](https://synthesizer-project.github.io) for flexible and fast generation of mock spectra and photometry, and uses the [LtU-ILI](https://ltu-ili.readthedocs.io/) package for fast, amortised posterior inference.
19
15
 
20
16
  ### Key Features
21
17
 
22
18
  - **Flexible Mock Generation**: Generate mock spectra and photometry using Synthesizer, allowing for full flexibility in almost every aspect of SED generation, including a wide range of post-processed stellar population synthesis grids.
23
- - **Flexible Training**: Mock photometry creation is seperated from the training of the inference model, allowing for flexible training strategies and the use of different inference models, as well as quickly switching between different feature sets - e.g. different filtersets, different noise models, etc.
19
+ - **Flexible Training**: Mock photometry creation is separated from the training of the inference model, allowing for flexible training strategies and the use of different inference models, as well as quickly switching between different feature sets - e.g. different filtersets, different noise models, etc.
24
20
  - **Fast Inference**: Leverage LtU-ILI for fast, amortised posterior inference, enabling efficient fitting of complex models to data.
25
21
 
26
22
  ### Requirements
27
23
 
28
- synference requires Python 3.10 or higher. It has the following dependencies:
24
+ Synference requires Python 3.10 or higher. It has the following dependencies:
29
25
 
30
26
  - [synthesizer](https://synthesizer-project.github.io) for mock generation
31
27
  - [ltu-ili](https://ltu-ili.readthedocs.io/) for inference
@@ -41,11 +37,17 @@ synference requires Python 3.10 or higher. It has the following dependencies:
41
37
  - [tqdm](https://tqdm.github.io/) for progress bars
42
38
  - [jax](https://jax.readthedocs.io/) for GPU acceleration (optional, for some inference models)
43
39
 
44
- These dependencies will be automatically installed when you install synference using pip.
40
+ These dependencies will be automatically installed when you install Synference using pip.
45
41
 
46
42
  ### Installation
47
43
 
48
- The easiest way to currently install synference is to clone the repository and install it in editable mode:
44
+ The easiest way to currently install Synference is from the PyPI repository.
45
+
46
+ ```bash
47
+ pip install synference
48
+ ```
49
+
50
+ If you want the latest development version you can also clone the repository and install it in editable mode:
49
51
 
50
52
  ```bash
51
53
  git clone https://www.github.com/synthesizer-project/synference.git
@@ -53,9 +55,11 @@ cd synference
53
55
  pip install -e .
54
56
  ```
55
57
 
58
+ Note that due to PyPI restrictions you will have to install [LtU-ILI](https://ltu-ili.readthedocs.io/en/latest/install.html) separately, as it can't be included as a dependency.
59
+
56
60
  ### Getting Started
57
61
 
58
- To get started with synference, you can check out the [examples](examples/) directory for usage examples and tutorials. The examples cover various aspects of using synference, including:
62
+ To get started with Synference, you can check out the [examples](examples/) directory for usage examples and tutorials. The examples cover various aspects of using Synference, including:
59
63
 
60
64
  - Generating mock spectra and photometry with Synthesizer
61
65
  - Training inference models with LtU-ILI
@@ -66,7 +70,7 @@ To get started with synference, you can check out the [examples](examples/) dire
66
70
 
67
71
  The most basic usage, for creating a simple mock catalogue and training a model on it looks like this:
68
72
 
69
- Firstly we setup the Synthesizer based model. More details on how to set up the Synthesizer model can be found in the [Synthesizer documentation](https://synthesizer-project.github.io/). Here we use a BPASS SPS grid, a lognormal star formation history, a single stellar metallicity and a simple emission model including Cloudy nebular emission but no dust reprocessing. The photometric filters used are common JWST/NIRCam wideband filters, but any filters supported by [SVO](https://svo2.cab.inta-csic.es/theory/fps/index.php) or loaded manually can be used. The model parameters are drawn from a Latin hypercube sampling of the parameter space, but this can be done in any way indepedent of synference. All we are providing to the grid generation is a set of *10,000* galaxies with a range of stellar masses, redshifts, metallicities, and star formation histories, and these can be created in any way you like.
73
+ Firstly we setup the Synthesizer based model. More details on how to set up the Synthesizer model can be found in the [Synthesizer documentation](https://synthesizer-project.github.io/). Here we use a BPASS SPS grid, a lognormal star formation history, a single stellar metallicity and a simple emission model including Cloudy nebular emission but no dust reprocessing. The photometric filters used are common JWST/NIRCam wideband filters, but any filters supported by [SVO](https://svo2.cab.inta-csic.es/theory/fps/index.php) or loaded manually can be used. The model parameters are drawn from a Latin hypercube sampling of the parameter space, but this can be done in any way independent of Synference. All we are providing to the grid generation is a set of *10,000* galaxies with a range of stellar masses, redshifts, metallicities, and star formation histories, and these can be created in any way you like.
70
74
 
71
75
  ```python
72
76
  from synthesizer.grid import Grid
@@ -158,17 +162,15 @@ empirical_model_fitter.recover_SED(observed_data_vector)
158
162
 
159
163
  ```
160
164
 
161
- This is just a basic example to get you started. synference is highly flexible and can be adapted to a wide range of use cases in simulation-based inference for SED fitting.
165
+ This is just a basic example to get you started. Synference is highly flexible and can be adapted to a wide range of use cases in simulation-based inference for SED fitting.
162
166
 
163
167
  ### Documentation
164
168
 
165
- Work in progress.
169
+ Documentation for Synference is available at [synthesizer-project.github.io/synference](https://synthesizer-project.github.io/synference/). The documentation includes installation instructions, tutorials, API references, and examples to help you get started with using Synference for your own projects.
166
170
 
167
171
  ### Contributing
168
172
 
169
- We welcome contributions to synference! If you have suggestions, bug reports, or would like to contribute code, please open an issue or submit a pull request on GitHub. Please see our [Code of Conduct](CODE_OF_CONDUCT.md) for more details on how to contribute and interact with the community.
173
+ We welcome contributions to Synference! If you have suggestions, bug reports, or would like to contribute code, please open an issue or submit a pull request on GitHub. Please see our [Code of Conduct](CODE_OF_CONDUCT.md) for more details on how to contribute and interact with the community.
170
174
 
171
175
  ### License
172
- This project is licensed under the GNU General Public License v3.0 (GPLv3). See the [LICENSE](LICENSE) file for details. This means you can use, modify, and distribute the code freely, but any derivative works must also be open source and distributed under the same license. We warn users that this software is offered "as is", without any warranty or guarantee of fitness for a particular purpose. synference is under active development, and therefore may change in the future.
173
-
174
-
176
+ This project is licensed under the GNU General Public License v3.0 (GPLv3). See the [LICENSE](LICENSE) file for details. This means you can use, modify, and distribute the code freely, but any derivative works must also be open source and distributed under the same license. We warn users that this software is offered "as is", without any warranty or guarantee of fitness for a particular purpose. Synference is under active development, and therefore may change in the future.
@@ -94,7 +94,7 @@ This will build a local copy of the documentation representative of the currentl
94
94
 
95
95
  ## Contributing to the Documentation
96
96
 
97
- The synference documentation is written in a combination of reStructuredText, Jupyter notebooks and Python scripts.
97
+ The Synference documentation is written in a combination of reStructuredText, Jupyter notebooks and Python scripts.
98
98
  Adding content should be relatively simple if you follow the instructions below.
99
99
 
100
100
  ### Adding notebooks
@@ -22,9 +22,9 @@ How do I deal with low sampling acceptance?
22
22
  -------------------------------------------
23
23
 
24
24
  A: You will be warned if your sampling acceptance is low during inference. Low sampling acceptance means that the model is predicting posterior samples which are outside the prior proposal range. To deal with this, you can try the following:
25
- - Increase the prior proposal range to ensure that the true parameters are within the prior support. For some parameters this can be reasonable, for example setting a slightly wider range for stellar mass.
26
- - Train a better model - low sampling acceptance can indicate that the model is not accurately capturing the posterior distribution. You can try training a more complex model, or using more training data to improve the model's performance.
27
- - You can check if a specific parameter is causing low sampling acceptance by looking at the acceptance per parameter during inference using the custom torch prior implemented in Synference. You can enable this by running `SBI_Fitter.create_priors(debug_sample_acceptance=True)` before inference. This will log the acceptance rate for each parameter, allowing you to identify any parameters that may be causing issues.
25
+ * Increase the prior proposal range to ensure that the true parameters are within the prior support. For some parameters this can be reasonable, for example setting a slightly wider range for stellar mass.
26
+ * Train a better model - low sampling acceptance can indicate that the model is not accurately capturing the posterior distribution. You can try training a more complex model, or using more training data to improve the model's performance.
27
+ * You can check if a specific parameter is causing low sampling acceptance by looking at the acceptance per parameter during inference using the custom torch prior implemented in Synference. You can enable this by running `SBI_Fitter.create_priors(debug_sample_acceptance=True)` before inference. This will log the acceptance rate for each parameter, allowing you to identify any parameters that may be causing issues.
28
28
 
29
29
  How do I load a previously trained model for inference?
30
30
  -------------------------------------------------------
@@ -40,4 +40,22 @@ A: You can load a previously trained model using the `SBI_Fitter.load_saved_mode
40
40
 
41
41
  This will load the model from the specified path and move it to the CPU for inference. You can then use this model to perform inference on new data. The model can be trained on GPU and then loaded on CPU for inference as shown above.
42
42
 
43
+ What other SBI tools are available for SED fitting and more generally for galaxy inference?
44
+ --------------------------------------------------------------------------------------------
45
+
46
+ There are a number of great tools out there for specific applications of SBI. This is not an exhaustive list (and feel free to suggest more), but below we've collated some of the useful tools we've found. Please cite the relevant papers if you use these tools.
47
+
48
+ 1. `SBIPIX <https://github.com/patriglesias/SBIPIX/>`_ - Published
49
+ `here <https://ui.adsabs.harvard.edu/abs/2025arXiv250604336I/abstract>`_.
50
+ Specifically for pixel-level inference from galaxy images, this
51
+ package provides pretrained models as well as the ability to train
52
+ your own models.
53
+ 2. `SBI++ <https://github.com/wangbingjie/sbi_pp>`_ - Published
54
+ `here <https://ui.adsabs.harvard.edu/abs/2023ApJ...952L..10W/abstract>`_,
55
+ this tool demonstrates a SBI workflow for SED fitting which can deal
56
+ with out of distribution noise and missing data.
57
+ 3. `SBI-SFHs <https://github.com/patriglesias/SBI_SFHs>`_ - Published
58
+ `here <https://www.aanda.org/articles/aa/abs/2024/09/aa49909-24/aa49909-24.html>`_
59
+ this tool recovers galaxy SFHS from spectroscopy.
60
+
43
61
 
@@ -6,6 +6,5 @@ In this section, we cover some advanced topics and features of Synference that g
6
6
  .. toctree::
7
7
  :maxdepth: 1
8
8
 
9
- nle
10
9
  custom_loop
11
10
  simformer
@@ -134,19 +134,138 @@
134
134
  "id": "6261165f",
135
135
  "metadata": {},
136
136
  "source": [
137
- "We recommend the Optuna dashboard for monitoring the progress of hyperparameter optimization. This can be launched using the following command:\n",
137
+ "We recommend [Optuna Dashboard](https://optuna-dashboard.readthedocs.io/en/latest/getting-started.html) for monitoring the progress of hyperparameter optimization. This can be launched using the following command:\n",
138
138
  "\n",
139
139
  "```bash\n",
140
140
  "optuna-dashboard your_sql_link\n",
141
141
  "```"
142
142
  ]
143
+ },
144
+ {
145
+ "cell_type": "markdown",
146
+ "id": "cc76e813",
147
+ "metadata": {},
148
+ "source": [
149
+ "## Custom Loop with a Fixed Model\n",
150
+ "\n",
151
+ "You can also use the custom training loop to train models with fixed parameter values, with a different configuration. This lets you take advantage of the additional features such as the customizable optimizer, model training checkpoints and ongoing training monitoring.\n",
152
+ "\n",
153
+ "Here is an example of the yaml file to train a specific fixed model, in this case a Neural Spline Flow, using the Adam optimizer, with 30 hidden features and 14 transforms."
154
+ ]
155
+ },
156
+ {
157
+ "cell_type": "markdown",
158
+ "id": "cb63e847",
159
+ "metadata": {},
160
+ "source": [
161
+ "```yaml\n",
162
+ "train_args:\n",
163
+ " skip_optimization: True\n",
164
+ " validation_fraction: 0.1\n",
165
+ " fixed_params:\n",
166
+ " model_choice: \"nsf\" # Must be a list\n",
167
+ " optimizer_choice: \"Adam\" # Must be a list\n",
168
+ " learning_rate: 0.0007460108070908076\n",
169
+ " training_batch_size: 79\n",
170
+ " stop_after_epochs: 57\n",
171
+ " clip_max_norm: 6.656577606872957\n",
172
+ " nsf_hidden_features: 30\n",
173
+ " nsf_num_transforms: 14\n",
174
+ "```"
175
+ ]
176
+ },
177
+ {
178
+ "cell_type": "code",
179
+ "execution_count": null,
180
+ "id": "be69d999",
181
+ "metadata": {},
182
+ "outputs": [],
183
+ "source": [
184
+ "config = {\n",
185
+ " \"train_args\": {\n",
186
+ " \"skip_optimization\": True,\n",
187
+ " \"validation_fraction\": 0.1,\n",
188
+ " \"fixed_params\": {\n",
189
+ " \"model_choice\": \"nsf\",\n",
190
+ " \"optimizer_choice\": \"Adam\",\n",
191
+ " \"learning_rate\": 0.0007460108070908076,\n",
192
+ " \"training_batch_size\": 79,\n",
193
+ " \"stop_after_epochs\": 57,\n",
194
+ " \"clip_max_norm\": 6.656577606872957,\n",
195
+ " \"nsf_hidden_features\": 30,\n",
196
+ " \"nsf_num_transforms\": 14,\n",
197
+ " },\n",
198
+ " }\n",
199
+ "}\n",
200
+ "\n",
201
+ "import yaml\n",
202
+ "\n",
203
+ "with open(\"config.yaml\", \"w\") as f:\n",
204
+ " yaml.dump(config, f)"
205
+ ]
206
+ },
207
+ {
208
+ "cell_type": "markdown",
209
+ "id": "29780005",
210
+ "metadata": {},
211
+ "source": [
212
+ "First we initialize a pre-configured model library."
213
+ ]
214
+ },
215
+ {
216
+ "cell_type": "code",
217
+ "execution_count": null,
218
+ "id": "0ca21ae1",
219
+ "metadata": {},
220
+ "outputs": [],
221
+ "source": [
222
+ "from synference import SBI_Fitter, test_data_dir\n",
223
+ "\n",
224
+ "fitter = SBI_Fitter.init_from_hdf5(\n",
225
+ " model_name=\"test\", hdf5_path=f\"{test_data_dir}/example_model_library.hdf5\"\n",
226
+ ")"
227
+ ]
228
+ },
229
+ {
230
+ "cell_type": "markdown",
231
+ "id": "00dae994",
232
+ "metadata": {},
233
+ "source": [
234
+ "Then we create our training arrays."
235
+ ]
236
+ },
237
+ {
238
+ "cell_type": "code",
239
+ "execution_count": null,
240
+ "id": "89b72d4c",
241
+ "metadata": {},
242
+ "outputs": [],
243
+ "source": [
244
+ "fitter.create_feature_array();"
245
+ ]
246
+ },
247
+ {
248
+ "cell_type": "markdown",
249
+ "id": "429f7303",
250
+ "metadata": {},
251
+ "source": [
252
+ "Now we can train a model - note that this is a terrible model with far too small a dataset, purely for demonstration purposes.\n",
253
+ "\n",
254
+ "The plotted live training loss curves look slightly odd in a notebook format, but you can see the live progress of your model on your training and validation set, and see where the best performing training epoch is."
255
+ ]
256
+ },
257
+ {
258
+ "cell_type": "code",
259
+ "execution_count": null,
260
+ "id": "7d8c65ce",
261
+ "metadata": {},
262
+ "outputs": [],
263
+ "source": [
264
+ "fitter.run_single_sbi(custom_config_yaml=\"config.yaml\")"
265
+ ]
143
266
  }
144
267
  ],
145
- "metadata": {
146
- "language_info": {
147
- "name": "python"
148
- }
149
- },
268
+ "metadata": {},
150
269
  "nbformat": 4,
151
270
  "nbformat_minor": 5
152
271
  }
@@ -0,0 +1,109 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "2291bddd",
6
+ "metadata": {},
7
+ "source": [
8
+ "### The Simformer\n",
9
+ "\n",
10
+ "[Gloeckler et al. 2024](https://arxiv.org/abs/2404.09636) introduced the Simformer, for 'all in one simulation based inference'.\n",
11
+ "\n",
12
+ "They use a novel probablistic diffusion model with a transformer architecture which learns the full joint distribution of parameters and data, allowing for fast, amortized Bayesian inference, without specifying beforehand which parameters are of interest. This makes the simformer approach particularly well suited to missing data, as the use of an attention mechanism allows the model sample from an arbitrary conditional distribution excluding any missing data."
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "markdown",
17
+ "id": "12ddb0a9",
18
+ "metadata": {},
19
+ "source": [
20
+ "The Simformer is currently implemented in two ways. The first way, is a seperate class called ```Simformer_Fitter```, which requires the user to install a [fork of the original simformer repo](https://github.com/tHarvey303/simformer/), which requires quite specific versions of CUDA, PyTorch and jax to work. \n",
21
+ "\n",
22
+ "The second way uses the new simformer implementation in the sbi package, which is currently only available in a pull request, but should be merged into the main branch soon. For now we will deal with this implementation, as it is much easier to install and use. There are examples of using the original approach in the examples/simformer folder of the synference repo.\n",
23
+ "\n",
24
+ "There are some limitations to the current sbi simformer implementation. Currently it doesn't seem to support serialization (due to the use of lambda functions), so models cannot be saved and loaded like other synference SBI models."
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": null,
30
+ "id": "6284d69d",
31
+ "metadata": {},
32
+ "outputs": [],
33
+ "source": [
34
+ "from synference import SBI_Fitter, test_data_dir\n",
35
+ "\n",
36
+ "fitter = SBI_Fitter.init_from_hdf5(\n",
37
+ " model_name=\"test\", hdf5_path=f\"{test_data_dir}/example_model_library.hdf5\"\n",
38
+ ")"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "markdown",
43
+ "id": "88192510",
44
+ "metadata": {},
45
+ "source": [
46
+ "We will create our training array as normal using the ```SBI_Fitter``` class."
47
+ ]
48
+ },
49
+ {
50
+ "cell_type": "code",
51
+ "execution_count": null,
52
+ "id": "96c2ff30",
53
+ "metadata": {},
54
+ "outputs": [],
55
+ "source": [
56
+ "fitter.create_feature_array();"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "markdown",
61
+ "id": "fe118ab9",
62
+ "metadata": {},
63
+ "source": [
64
+ "There are a few parameters to be aware of:\n",
65
+ "\n",
66
+ "1. ```sde_type``` : The type of SDE to use. Options are 've` (variance exploding), 'vp' (variance preserving) or 'subvp' (sub variance preserving). This doesn't do anything for the flow based simformer.\n",
67
+ "2. ```simformer_type```: 'score' or 'flow'- whether to use a score based or flow based simformer. \n",
68
+ "3 ```learning_rate```: The learning rate to use for training.\n",
69
+ "4. ```model_kwargs```: A dictionary of additional keyword arguments to pass to the simformer model. These can include:\n",
70
+ " - ```num_layers```: The number of transformer layers to use.\n",
71
+ " - ```num_heads```: The number of attention heads to use.\n",
72
+ " - ```dim_val```: The dimension of the value vectors in the attention mechanism.\n",
73
+ " - ```dim_id```: The dimension of the identity vectors in the attention mechanism.\n",
74
+ " - ```mlp_ratio``` : The ratio of the hidden dimension to the input dimension in the MLP layers.\n",
75
+ " - ```hidden_features```: The number of hidden features to use in the MLP layers.\n",
76
+ " - ```time_embedding_dim```: The dimension of the time embedding.\n",
77
+ "\n",
78
+ "Like all other synference models we can also set the ```training_batch_size```, ```validation_fraction```, ```stop_after_epochs``` and ```clip_max_norm``` parameters.\n",
79
+ "\n",
80
+ "```python\n",
81
+ "\n",
82
+ "fitter.run_single_simformer(\n",
83
+ " name_append=\"simformer_test\",\n",
84
+ " sde_type=\"ve\",\n",
85
+ " simformer_type=\"score\",\n",
86
+ " learning_rate=1e-5,\n",
87
+ " training_batch_size=64,\n",
88
+ " model_kwargs={\n",
89
+ " \"hidden_features\": 128,\n",
90
+ " \"n_layers\": 6,\n",
91
+ " \"dim_val\": 64,\n",
92
+ " \"dim_id\": 64,\n",
93
+ " \"mlp_ratio\": 4,\n",
94
+ " \"time_embedding_dim\": 32,\n",
95
+ " \"num_heads\": 4,\n",
96
+ " },\n",
97
+ " load_existing_model=False,\n",
98
+ " validation_fraction=0.1,\n",
99
+ " stop_after_epochs=30,\n",
100
+ " plot=False, # Currently the LtU-ILI plotting doesn't work with the simformer\n",
101
+ ")\n",
102
+ "```"
103
+ ]
104
+ }
105
+ ],
106
+ "metadata": {},
107
+ "nbformat": 4,
108
+ "nbformat_minor": 5
109
+ }