Skip to content

Commit c250255

Browse files
add model architecture using mermaid
1 parent 44a019c commit c250255

File tree

8 files changed

+123
-3
lines changed

8 files changed

+123
-3
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
1212
rev: "v6.0.0"
1313
hooks:
14-
#- id: check-added-large-files
14+
- id: check-added-large-files
1515
- id: check-ast
1616
- id: check-case-conflict
1717
- id: check-json
1818
- id: check-merge-conflict
1919
- id: check-symlinks
2020
- id: check-yaml
21+
exclude: ^mkdocs\.yml$ # otherwise !!python/name:mermaid2.fence_mermaid in .mkdocs.yaml make it fail
2122
- id: debug-statements
2223
- id: detect-private-key
2324
- id: end-of-file-fixer

docs/NAVIGATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ See https://oprypin.github.io/mkdocs-literate-nav/
99
- [Tutorials](tutorials/index.md)
1010
- [Further background](further-background/index.md)
1111
- [Dependency pinning and testing](further-background/dependency-pinning-and-testing.md)
12+
- [Model architecture](further-background/model-architecture.md)
1213
- [Development](development.md)
1314
- [API reference](api/pymc_elicito/)
1415
- [Changelog](changelog.md)

docs/further-background/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ Points we will aim to cover:
1111
- Why it was created
1212
- Help the reader make connections
1313

14-
We will aim to avoid writing instructions or technical descriptions here,
15-
they belong elsewhere.
14+
We will aim to avoid writing instructions or technical descriptions here, they belong elsewhere.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
```mermaid
2+
flowchart TB
3+
subgraph eliobj["Elicit class (user input)"]
4+
input["Model, Parameters, Targets, \n Network, Initializer, Optimizer, \n Meta-Setting"]
5+
expert_dat["expert elicited summaries"]
6+
end
7+
subgraph initialization["initialization"]
8+
initializer["initializer"]
9+
hyper_parametric("prior parameters")
10+
hyper_deep("weights/biases of DNNs")
11+
end
12+
13+
subgraph subGraph3["priors"]
14+
transformation["transform to constrained space"]
15+
prior["sample from prior in \n unconstrained space"]
16+
end
17+
subgraph model["model"]
18+
generative_model["run generative model \n in forward mode"]
19+
end
20+
subgraph summaries["summaries"]
21+
elicits["elicited summaries"]
22+
summary["target quantities"]
23+
end
24+
subgraph loss["loss"]
25+
total_loss["total loss"]
26+
indiv_loss["individual losses"]
27+
end
28+
subgraph optimization["optimization"]
29+
gradients["gradients"]
30+
end
31+
subgraph training["training"]
32+
subGraph3
33+
prior_samples[/"prior samples"/]
34+
model
35+
model_output[/"model simulations"/]
36+
summaries
37+
simulated_summaries[/"simulated summaries"/]
38+
loss
39+
optimization
40+
check{"convergence \n criterion"}
41+
train_vars[/"trainable variables \n (=hyperparameters)"/]
42+
end
43+
input --> initializer
44+
initializer -- if parametric prior --> hyper_parametric
45+
initializer -- if deep prior --> hyper_deep
46+
hyper_parametric --> train_vars
47+
hyper_deep --> train_vars
48+
train_vars --> prior
49+
expert_dat --> indiv_loss & input
50+
prior --> transformation
51+
transformation --> prior_samples
52+
prior_samples --> generative_model
53+
generative_model --> model_output
54+
model_output --> summary
55+
summary --> elicits
56+
elicits --> simulated_summaries
57+
simulated_summaries --> indiv_loss
58+
indiv_loss --> total_loss
59+
total_loss --> gradients
60+
gradients --> check
61+
check -- not reached:<br> update --> train_vars
62+
check -- reached --> stop((("stop")))
63+
64+
classDef data shape: lean-r
65+
class prior_samples data
66+
```

mkdocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ theme:
2828
name: Switch to light mode
2929

3030
plugins:
31+
- mermaid2
3132
# https://mkdocstrings.github.io/autorefs/
3233
- autorefs
3334
# Required for auto-generating our documentation stubs
@@ -121,6 +122,11 @@ plugins:
121122
- section-index
122123

123124
markdown_extensions:
125+
- pymdownx.superfences:
126+
custom_fences:
127+
- name: mermaid
128+
class: mermaid
129+
format: !!python/name:mermaid2.fence_mermaid
124130
# https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/#attribute-lists
125131
- attr_list
126132
- footnotes

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ dev = [
9696
docs = [
9797
# Key dependencies
9898
# ----------------
99+
"mkdocs-mermaid2-plugin>=1.2.3",
99100
"attrs==25.3.0",
100101
"mkdocs-autorefs==1.4.2",
101102
"mkdocs-gen-files==0.5.0",

requirements-docs-locked.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ cycler==0.12.1
2525
debugpy==1.8.11
2626
decorator==5.1.1
2727
defusedxml==0.7.1
28+
editorconfig==0.17.1
2829
exceptiongroup==1.3.0 ; python_full_version < '3.11'
2930
executing==2.1.0
3031
fastjsonschema==2.21.1
@@ -46,6 +47,7 @@ ipython-pygments-lexers==1.1.1 ; python_full_version >= '3.11'
4647
isoduration==20.11.0
4748
jedi==0.19.2
4849
jinja2==3.1.5
50+
jsbeautifier==1.15.4
4951
json5==0.10.0
5052
jsonpointer==3.0.0
5153
jsonschema==4.23.0
@@ -80,6 +82,7 @@ mkdocs-jupyter==0.25.1
8082
mkdocs-literate-nav==0.6.2
8183
mkdocs-material==9.6.16
8284
mkdocs-material-extensions==1.3.1
85+
mkdocs-mermaid2-plugin==1.2.3
8386
mkdocs-section-index==0.3.10
8487
mkdocstrings==0.30.0
8588
mkdocstrings-python==1.16.12

uv.lock

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)