Skip to content

Commit

Permalink
Merge pull request #328 from andreasgrv/generative-notebook-2
Browse files Browse the repository at this point in the history
MNIST Classification notebook
  • Loading branch information
loreloc authored Dec 16, 2024
2 parents c5879db + a54e356 commit 7f40e53
Show file tree
Hide file tree
Showing 6 changed files with 1,243 additions and 11 deletions.
4 changes: 3 additions & 1 deletion cirkit/templates/data_modalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def image_data(
num_input_units: int,
sum_product_layer: str,
num_sum_units: int,
num_classes: int = 1,
input_params: dict[str, Parameterization] | None = None,
sum_weight_param: Parameterization | None = None,
use_mixing_weights: bool = True,
Expand All @@ -47,6 +48,7 @@ def image_data(
of a hadamard product layer followed by a single dense layer), 'tucker' (the Tucker
decomposition layer, consisting of a kronecker product layer followed by a single dense
layer).
num_classes: The number of output classes (default=1).
num_sum_units: The number of sum units in each sum layer, i.e., either dense or mixing
layer.
input_params: A dictionary mapping each name of a parameter of the input layer to
Expand Down Expand Up @@ -136,6 +138,6 @@ def image_data(
num_channels=image_shape[0],
num_input_units=num_input_units,
num_sum_units=num_sum_units,
num_classes=1,
num_classes=num_classes,
factorize_multivariate=True,
)
17 changes: 7 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ hide:
- :fontawesome-solid-screwdriver-wrench:{ .lg .middle } __Build a circuit...__

---
[:octicons-arrow-right-24: from region graphs](https://github.com/april-tools/cirkit/blob/main/notebooks/region-graphs-and-parametrisation.ipynb)
[:octicons-arrow-right-24: from region graphs](https://cirkit-docs.readthedocs.io/en/latest/notebooks/region-graphs-and-parametrisation)

<!--
Expand All @@ -40,23 +40,20 @@ hide:
- :fontawesome-solid-gears:{ .lg .middle } __Learn a circuit...__

---
[:octicons-arrow-right-24: for distribution estimation :fontawesome-solid-chart-area:{.lg}](https://github.com/april-tools/cirkit/blob/main/notebooks/learning-a-circuit.ipynb)
[:octicons-arrow-right-24: for distribution estimation :fontawesome-solid-chart-area:{.lg}](https://cirkit-docs.readthedocs.io/en/latest/notebooks/learning-a-circuit)

[:octicons-arrow-right-24: for tensor compression :fontawesome-solid-file-zipper:](https://github.com/april-tools/cirkit/blob/main/notebooks/compression-cp-factorization.ipynb)
[:octicons-arrow-right-24: for tensor compression :fontawesome-solid-file-zipper:](https://cirkit-docs.readthedocs.io/en/latest/notebooks/compression-cp-factorization)

[:octicons-arrow-right-24: ... all of the above, with PICs :fontawesome-solid-camera:](https://github.com/april-tools/cirkit/blob/main/notebooks/learning-a-circuit-with-pic.ipynb)
[:octicons-arrow-right-24: as a (generative) multi-class classifier](https://cirkit-docs.readthedocs.io/en/latest/notebooks/generative-vs-discriminative-circuit)

<!--
[:octicons-arrow-right-24: as a (generative) multi-class classifier](#)
--->
[:octicons-arrow-right-24: ... all of the above, with PICs :fontawesome-solid-camera:{.lg}](https://cirkit-docs.readthedocs.io/en/latest/notebooks/learning-a-circuit-with-pic)

- :material-scale-balance:{ .lg .middle }__Advanced reasoning...__

---
[:octicons-arrow-right-24: with squared circuits $($:fontawesome-solid-plug-circle-minus:{.lg}$)^2$](https://github.com/april-tools/cirkit/blob/main/notebooks/sum-of-squares-circuits.ipynb)
[:octicons-arrow-right-24: with squared circuits $($:fontawesome-solid-plug-circle-minus:{.lg}$)^2$](https://cirkit-docs.readthedocs.io/en/latest/notebooks/sum-of-squares-circuits)

[:octicons-arrow-right-24: with logic circuits :fontawesome-solid-square-binary:{.lg}...](https://github.com/april-tools/cirkit/blob/main/notebooks/logic-circuits.ipynb)
[:octicons-arrow-right-24: with logic circuits :fontawesome-solid-square-binary:{.lg}...](https://cirkit-docs.readthedocs.io/en/latest/notebooks/logic-circuits)

</br>
...to enforce constraints in neural nets
Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/generative-vs-discriminative-circuit.ipynb
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ nav:
- nb5: 'notebooks/learning-a-circuit-with-pic.ipynb'
- nb6: 'notebooks/logic-circuits.ipynb'
- nb7: 'notebooks/compression-cp-factorization.ipynb'
- nb8: 'notebooks/generative-vs-discriminative-circuit.ipynb'
- API documentation: 'api/'
plugins:
- search
Expand Down
1 change: 1 addition & 0 deletions notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ graph TD;
A[<a href='https://github.com/april-tools/cirkit/blob/main/notebooks/learning-a-circuit.ipynb'>Learning a circuit</a>]-->B[<a href='https://github.com/april-tools/cirkit/blob/main/notebooks/compilation-options.ipynb'>Compilation Options</a>];
A-->C[<a href='https://github.com/april-tools/cirkit/blob/main/notebooks/region-graphs-and-parametrisation.ipynb'>Region Graphs and Parametrisation</a>];
A-->D[<a href='https://github.com/april-tools/cirkit/blob/main/notebooks/learning-a-circuit-with-pic.ipynb'>Probabilistic Integral Circuits</a>];
A-->H[<a href='https://github.com/april-tools/cirkit/blob/main/notebooks/generative-vs-discriminative-circuit.ipynb'>Building an MNIST Classifier using Cirkit</a>];
B-->E[<a href='https://github.com/april-tools/cirkit/blob/main/notebooks/sum-of-squares-circuits.ipynb'>Sum of Squares Circuits</a>];
C-->E;
B-->F[<a href='https://github.com/april-tools/cirkit/blob/main/notebooks/compression-cp-factorization.ipynb'>CP Tensor Factorization</a>];
Expand Down
1,230 changes: 1,230 additions & 0 deletions notebooks/generative-vs-discriminative-circuit.ipynb

Large diffs are not rendered by default.

0 comments on commit 7f40e53

Please sign in to comment.