Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ReducedSystem and renamed to HRedSys (including tutorial) #140

Merged
merged 57 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
727b7e8
Removed system types (not needed anymore).
benedict-96 Apr 25, 2024
01f5041
Added type stability for all fields in struct.
benedict-96 Apr 25, 2024
969418d
Removed system type.
benedict-96 Apr 25, 2024
5b94a71
Added GeometricProblems for testing purposes.
benedict-96 Apr 25, 2024
815167d
Introduced SymplecticCompression (super type of SymplecticAutoencoder…
benedict-96 Apr 25, 2024
2f80629
src/architectures/psd.jl
benedict-96 Apr 25, 2024
0eae44d
Using SymplecticCompression, SymplecticEncoder and SymplecticDecoder …
benedict-96 Apr 25, 2024
7a30e79
Added test for reduced system.
benedict-96 Apr 25, 2024
d102c1f
Modified constructors for the reduced system.
benedict-96 Apr 25, 2024
65b35d3
Added new ReducedSystem test and changed order of tests.
benedict-96 Apr 25, 2024
7925ee6
Now using GeometricSolutions instead of GeometricEquations.
benedict-96 Apr 25, 2024
33dc2f1
Add ODEProblem and HODEProblem.
benedict-96 Apr 25, 2024
891d505
Added option of calling data loader with a GeometricSolution (instead…
benedict-96 Apr 25, 2024
f380428
Also using ODEEnsemble and HODEEnsemble now.
benedict-96 Apr 25, 2024
ee94ecc
Added GeometricSolutions.
benedict-96 Apr 25, 2024
e2a7093
Input is the network, not the architecture
benedict-96 Apr 25, 2024
7fc8db3
Added option to call layer on NamedTuple.
benedict-96 Apr 29, 2024
3e27652
Added _elltype to also work with network parameters.
benedict-96 Apr 29, 2024
f93aae4
vat -> vcat.
benedict-96 Apr 29, 2024
95234cd
Fixed missing input argument.
benedict-96 Apr 29, 2024
7eff536
SymplecticReducedSystem -> HRedSys & not exporting all related functi…
benedict-96 Apr 29, 2024
682f580
Introduced const SymplecticDimensionChange to summerize some function…
benedict-96 Apr 29, 2024
946829c
Added additional assert that checks that full_dim is bigger than redu…
benedict-96 Apr 29, 2024
f14e355
Removed unnecessary argument.
benedict-96 Apr 29, 2024
c3459b2
elltype -> eltype.
benedict-96 Apr 29, 2024
d917986
Improved readibility.
benedict-96 Apr 30, 2024
7dbaf15
Also using StateVariable now (may not be needed after all).
benedict-96 Apr 30, 2024
b4e7b94
Introduced function data_matrices_from_geometric_solution. This is al…
benedict-96 Apr 30, 2024
9657dbe
Cleaned up code.
benedict-96 Apr 30, 2024
d9fe5c6
Only the reduced dimension can be picked here. The actual system dime…
benedict-96 Apr 30, 2024
c5815ef
Added asserts to check that the number of blocks isn't chosen too big.
benedict-96 Apr 30, 2024
11f6438
Using Zygote instead of ForwardDiff now and renamed build_reduced_f -…
benedict-96 Apr 30, 2024
3b245f8
Testing different integrators.
benedict-96 Apr 30, 2024
723a279
Renamed functions to something that better conforms with GI.
benedict-96 May 1, 2024
8c17ea6
Using ForwardDiff for HRedSys and Finite differences for some tests.
benedict-96 May 2, 2024
d45eb74
Using ForwardDiff (for HRedSys).
benedict-96 May 2, 2024
29038f4
Made PSD layer work for different input arrays (for ForwardDiff).
benedict-96 May 2, 2024
dc85b47
Implemented some hacks to get around ForwardDiff limitations.
benedict-96 May 2, 2024
6bf11d6
Included test for divergence-free vf.
benedict-96 May 2, 2024
ddd5dd7
Included decoder in function for evaluating variables as well as gett…
benedict-96 May 2, 2024
2897ece
Merge branch 'main' into reduced_system
benedict-96 May 3, 2024
bfbe855
Removed _get.
benedict-96 May 3, 2024
ca1564e
SymplecticDecoder -> NonLinearSymplecticDecoder.
benedict-96 May 3, 2024
3ebec00
Got rid of _get.
benedict-96 May 3, 2024
69ae109
Updated tutorial.
benedict-96 May 3, 2024
c22f488
Specified specific example.
benedict-96 May 3, 2024
11e830a
Fixed determination of input.
benedict-96 May 5, 2024
091e98d
Fixed determination of backend.
benedict-96 May 5, 2024
b3497dd
Renamed file.
benedict-96 May 6, 2024
018882e
Added short description of symplectic autoencoder architecture.
benedict-96 May 6, 2024
849fb25
Added symplectic autoencoder architecture.
benedict-96 May 6, 2024
beb8930
Fixed references.
benedict-96 May 6, 2024
9c11376
Added docstrings.
benedict-96 May 6, 2024
468e4b8
Fixed reference in docstring.
benedict-96 May 6, 2024
7a2dd1b
Added GeometricProblems.
benedict-96 May 6, 2024
72e2400
linear wave -> toda lattice.
benedict-96 May 6, 2024
4462569
Decoder -> SymplecticDecoder; Encoder -> SymplecticEncoder.
benedict-96 May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading