Skip to content

Commit

Permalink
Merge pull request #140 from JuliaGNI/reduced_system
Browse files Browse the repository at this point in the history
Updated `ReducedSystem` and renamed to `HRedSys` (including tutorial)
  • Loading branch information
michakraus authored May 7, 2024
2 parents 7aa4e60 + 4462569 commit d3b8faf
Show file tree
Hide file tree
Showing 24 changed files with 691 additions and 207 deletions.
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GeometricBase = "9a0b12b7-583b-4f04-aa1f-d8551b6addc9"
GeometricEquations = "c85262ba-a08a-430a-b926-d29770767bf2"
GeometricIntegrators = "dcce2d33-59f6-5b8d-9047-0defad88ae06"
GeometricSolutions = "7843afe4-64f4-4df4-9231-049495c56661"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Expand Down Expand Up @@ -52,6 +54,7 @@ julia = "1.8"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
GeometricEquations = "c85262ba-a08a-430a-b926-d29770767bf2"
GeometricProblems = "18cb22b4-ad41-5c80-9c5f-710df63fbdc9"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -60,4 +63,4 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ChainRulesTestUtils", "Random", "SafeTestsets", "Test"]
test = ["ChainRulesTestUtils", "Random", "SafeTestsets", "Test", "GeometricProblems", "FiniteDifferences"]
3 changes: 2 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GeometricBase = "9a0b12b7-583b-4f04-aa1f-d8551b6addc9"
GeometricEquations = "c85262ba-a08a-430a-b926-d29770767bf2"
GeometricIntegrators = "dcce2d33-59f6-5b8d-9047-0defad88ae06"
GeometricMachineLearning = "194d25b2-d3f5-49f0-af24-c124f4aa80cc"
GeometricProblems = "18cb22b4-ad41-5c80-9c5f-710df63fbdc9"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Expand All @@ -19,4 +20,4 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ makedocs(;
"Home" => "index.md",
"Architectures" => [
"SympNet" => "architectures/sympnet.md",
"Symplectic Autoencoders" => "architectures/symplectic_autoencoder.md",
],
"Manifolds" => [
"Concepts from General Topology" => "manifolds/basic_topology.md",
Expand Down Expand Up @@ -90,7 +91,7 @@ makedocs(;
],
"Tutorials" =>[
"Sympnets" => "tutorials/sympnet_tutorial.md",
"Linear Wave Equation" => "tutorials/linear_wave_equation.md",
"Symplectic Autoencoders" => "tutorials/symplectic_autoencoder.md",
"MNIST" => "tutorials/mnist_tutorial.md",
"Grassmann manifold" => "tutorials/grassmann_layer.md",
"Volume-Preserving Attention" => "tutorials/volume_preserving_attention.md",
Expand Down
28 changes: 28 additions & 0 deletions docs/src/architectures/symplectic_autoencoder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Symplectic Autoencoder

A visualization of an instance of [SymplecticAutoencoder](@ref) is shown below:

```@example
import Images, Plots # hide
if Main.output_type == :html # hide
HTML("""<object type="image/svg+xml" class="display-light-only" data=$(joinpath(Main.buildpath, "../tikz/symplectic_autoencoder_architecture.png"))></object>""") # hide
else # hide
Plots.plot(Images.load("../tikz/symplectic_autoencoder_architecture.png"), axis=([], false)) # hide
end # hide
```

```@example
if Main.output_type == :html # hide
HTML("""<object type="image/svg+xml" class="display-dark-only" data=$(joinpath(Main.buildpath, "../tikz/symplectic_autoencoder_architecture_dark.png"))></object>""") # hide
end # hide
```

The *intermediate dimension* ``M`` is calculated via `n : (N - n) ÷ (n_blocks - 1) : N`. Further we have the following choices:
- `n_encoder_layers::Integer = 4`
- `n_encoder_blocks::Integer = 2`
- `n_decoder_layers::Integer = 2`
- `n_decoder_blocks::Integer = 3`
- `encoder_init_q::Bool = true`
- `decoder_init_q::Bool = true`

Note that all of these are keyword arguments that can be supplied to [SymplecticAutoencoder](@ref).
2 changes: 2 additions & 0 deletions docs/src/tikz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ png:
pdftocairo -png -r $(res1) -transp -singlefile logo.pdf logo
pdftocairo -png -r $(res1) -transp -singlefile symplectic_autoencoder.pdf symplectic_autoencoder
pdftocairo -png -r $(res1) -transp -singlefile symplectic_autoencoder_dark.pdf symplectic_autoencoder_dark
pdftocairo -png -r $(res1) -transp -singlefile symplectic_autoencoder_architecture.pdf symplectic_autoencoder_architecture
pdftocairo -png -r $(res1) -transp -singlefile symplectic_autoencoder_architecture_dark.pdf symplectic_autoencoder_architecture_dark
pdftocairo -png -r $(res1) -transp -singlefile solution_manifold_2.pdf solution_manifold_2
pdftocairo -png -r $(res1) -transp -singlefile mha.pdf mha
pdftocairo -png -r $(res1) -transp -singlefile mha_dark.pdf mha_dark
Expand Down
69 changes: 69 additions & 0 deletions docs/src/tikz/symplectic_autoencoder_architecture.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
\documentclass[crop, tikz]{standalone}

\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[mode=buildnew]{standalone}

\usepackage{xcolor}


\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{fit}
%\usepackage{nicematrix}

\tikzset{set/.style={draw,circle,inner sep=0pt,align=center}}

\definecolor{morange}{RGB}{255,127,14}
\definecolor{mblue}{RGB}{31,119,180}
\definecolor{mred}{RGB}{214,39,40}
\definecolor{mpurple}{RGB}{148,103,189}
\definecolor{mgreen}{RGB}{44,160,44}


\begin{document}
\begin{tikzpicture}[module/.style={draw, very thick, rounded corners, minimum width=15ex},
gradient/.style={module, fill=mgreen!50},
psd/.style={module, fill=mblue!50},
arrow/.style={-stealth, thick, rounded corners},
]
\node (input) {Input};
\node[above of=input, gradient, align=center, yshift=.6cm] (gq1) {\texttt{GradientQ(2N, 10N, tanh)}};
\node[above of=gq1, gradient, align=center] (gq2) {\texttt{GradientP(2N, 10N, tanh)}};
\node[above of=gq2, gradient, align=center] (gq3) {\texttt{GradientQ(2N, 10N, tanh)}};
\node[above of=gq3, gradient, align=center] (gq4) {\texttt{GradientP(2N, 10N, tanh)}};
\node[above of=gq4, psd, align=center] (psd1) {\texttt{PSDLayer(2N, 2n)}};

\node[right of=input, xshift=6cm] (output) {Output};
\node[above of=output, psd] (psd3) {\texttt{PSDLayer(2M, 2N)}};
\node[above of=psd3, gradient] (gq8) {\texttt{GradientP(2M, 2M, tanh)}};
\node[above of=gq8, gradient] (gq7) {\texttt{GradientQ(2M, 2M, tanh)}};
\node[above of=gq7, psd] (psd2) {\texttt{PSDLayer(2n, 2M)}};
\node[above of=psd2, gradient] (gq6) {\texttt{GradientP(2n, 10n, tanh)}};
\node[above of=gq6, gradient] (gq5) {\texttt{GradientQ(2n, 10n, tanh)}};

\draw[arrow] (gq1) -- (gq2);
\draw[arrow] (gq2) -- (gq3);
\draw[arrow] (gq3) -- (gq4);
\draw[arrow] (gq4) -- (psd1);

\coordinate[above of=gq5] (gq5_above);
\coordinate[left of=gq5_above, xshift=-6cm] (psd_above);

\draw[arrow] (gq5) -- (gq6);
\draw[arrow] (gq6) -- (psd2);
\draw[arrow] (psd2) -- (gq7);
\draw[arrow] (gq7) -- (gq8);
\draw[arrow] (gq8) -- (psd3);

\node[fit=(gq1)(gq2)(gq3)(gq4)(psd1),draw, ultra thick, rounded corners, label=left:$\Psi^e$] (encoder) {};
\node[fit=(gq5)(gq5)(gq7)(psd2)(gq7)(gq8)(psd3),draw, ultra thick, rounded corners, label=left:$\Psi^d$] (decoder) {};

\draw[arrow] (encoder.north)-|(psd_above)-|(gq5_above)--(decoder.north);
\draw[arrow] (input) -- (encoder);
\draw[arrow] (decoder) -- (output);


\end{tikzpicture}
\end{document}
69 changes: 69 additions & 0 deletions docs/src/tikz/symplectic_autoencoder_architecture_dark.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
\documentclass[crop, tikz]{standalone}

\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[mode=buildnew]{standalone}

\usepackage{xcolor}


\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{fit}
%\usepackage{nicematrix}

\tikzset{set/.style={draw,circle,inner sep=0pt,align=center}}

\definecolor{morange}{RGB}{255,127,14}
\definecolor{mblue}{RGB}{31,119,180}
\definecolor{mred}{RGB}{214,39,40}
\definecolor{mpurple}{RGB}{148,103,189}
\definecolor{mgreen}{RGB}{44,160,44}


\begin{document}
\begin{tikzpicture}[module/.style={draw, very thick, rounded corners, minimum width=15ex},
gradient/.style={module, fill=mgreen!50},
psd/.style={module, fill=mblue!50},
arrow/.style={-stealth, thick, rounded corners},
]
\node (input) {\color{white} Input};
\node[above of=input, gradient, align=center, yshift=.6cm] (gq1) {\texttt{GradientQ(2N, 10N, tanh)}};
\node[above of=gq1, gradient, align=center] (gq2) {\texttt{GradientP(2N, 10N, tanh)}};
\node[above of=gq2, gradient, align=center] (gq3) {\texttt{GradientQ(2N, 10N, tanh)}};
\node[above of=gq3, gradient, align=center] (gq4) {\texttt{GradientP(2N, 10N, tanh)}};
\node[above of=gq4, psd, align=center] (psd1) {\texttt{PSDLayer(2N, 2n)}};

\node[right of=input, xshift=6cm] (output) {\color{white} Output};
\node[above of=output, psd] (psd3) {\texttt{PSDLayer(2M, 2N)}};
\node[above of=psd3, gradient] (gq8) {\texttt{GradientP(2M, 2M, tanh)}};
\node[above of=gq8, gradient] (gq7) {\texttt{GradientQ(2M, 2M, tanh)}};
\node[above of=gq7, psd] (psd2) {\texttt{PSDLayer(2n, 2M)}};
\node[above of=psd2, gradient] (gq6) {\texttt{GradientP(2n, 10n, tanh)}};
\node[above of=gq6, gradient] (gq5) {\texttt{GradientQ(2n, 10n, tanh)}};

\draw[arrow, color=white] (gq1) -- (gq2);
\draw[arrow, color=white] (gq2) -- (gq3);
\draw[arrow, color=white] (gq3) -- (gq4);
\draw[arrow, color=white] (gq4) -- (psd1);

\coordinate[above of=gq5] (gq5_above);
\coordinate[left of=gq5_above, xshift=-6cm] (psd_above);

\draw[arrow, color=white] (gq5) -- (gq6);
\draw[arrow, color=white] (gq6) -- (psd2);
\draw[arrow, color=white] (psd2) -- (gq7);
\draw[arrow, color=white] (gq7) -- (gq8);
\draw[arrow, color=white] (gq8) -- (psd3);

\node[fit=(gq1)(gq2)(gq3)(gq4)(psd1),draw, ultra thick, rounded corners, color=white, label=left:\color{white}$\Psi^e$] (encoder) {};
\node[fit=(gq5)(gq5)(gq7)(psd2)(gq7)(gq8)(psd3),draw, ultra thick, rounded corners, color=white, label=left:\color{white}$\Psi^d$] (decoder) {};

\draw[arrow, color=white] (encoder.north)-|(psd_above)-|(gq5_above)--(decoder.north);
\draw[arrow, color=white] (input) -- (encoder);
\draw[arrow, color=white] (decoder) -- (output);


\end{tikzpicture}
\end{document}
94 changes: 0 additions & 94 deletions docs/src/tutorials/linear_wave_equation.md

This file was deleted.

Loading

0 comments on commit d3b8faf

Please sign in to comment.