Skip to content

Commit

Permalink
progress on documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mfinzi committed Mar 3, 2021
1 parent 4061a7f commit a4c4be0
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A type system for the automated construction of equivariant layers.
.. toctree::
:maxdepth: 1
:caption: Notes

inner_workings.md
CHANGELOG.md

.. toctree::
Expand Down
1 change: 1 addition & 0 deletions docs/inner_workings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Inner Workings
14 changes: 14 additions & 0 deletions docs/notebooks/building_a_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@
"model = EMLP(dataset.rep_in,dataset.rep_out,group=G,num_layers=3,ch=256)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 5,
Expand Down
8 changes: 8 additions & 0 deletions docs/notebooks/building_a_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ from emlp.models.mlp import EMLP
model = EMLP(dataset.rep_in,dataset.rep_out,group=G,num_layers=3,ch=256)
```

```{code-cell} ipython3
```

```{code-cell} ipython3
```

```{code-cell} ipython3
from emlp.models.mlp import uniform_rep
r = uniform_rep(512,G)
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/mixed_tensors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kernelspec:
name: python3
---

# mixed_tensors
# Combining Representations from Different Groups

```{code-cell} ipython3
Expand Down
6 changes: 2 additions & 4 deletions docs/notebooks/new_groups.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# New Groups"
"# Implementing a New Group"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": []
}
],
Expand Down
6 changes: 2 additions & 4 deletions docs/notebooks/new_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ kernelspec:
name: python3
---

# New Groups
# Implementing a New Group

```{code-cell} ipython3
```
+++
2 changes: 1 addition & 1 deletion docs/notebooks/new_representations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# New Representations"
"# Implementing New Representations"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/new_representations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kernelspec:
name: python3
---

# New Representations
# Implementing New Representations

```{code-cell} ipython3
Expand Down
13 changes: 6 additions & 7 deletions docs/notebooks/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
"repin = V(G)\n",
"repout = V(G)\n",
"conv_basis = (repin>>repout).symmetric_basis()\n",
"print(conv_basis.shape)"
"print(f\"Conv basis has shape {conv_basis.shape}\")"
]
},
{
Expand Down Expand Up @@ -402,8 +402,8 @@
" plt.axis('off')\n",
"\n",
"def vis(repin,repout,cluster=True):\n",
" Q = (repin>>repout).symmetric_basis()\n",
" vis_basis(Q,(repout.size(),repin.size()),cluster)"
" Q = (repin>>repout).symmetric_basis() # compute the equivariant basis\n",
" vis_basis(Q,(repout.size(),repin.size()),cluster) # visualize it"
]
},
{
Expand Down Expand Up @@ -534,7 +534,7 @@
"repin = V(S(6))**2\n",
"repout = V(S(6))**2\n",
"vis(repin,repout)\n",
"print((repin>>repout).symmetric_basis().shape)"
"print(f\"Basis matrix of shape {(repin>>repout).symmetric_basis().shape}\")"
]
},
{
Expand Down Expand Up @@ -723,9 +723,8 @@
"W = V(S(6))\n",
"repin = W+W**2 # (one set feature and one edge feature)\n",
"repout = W # (one set feature)\n",
"\n",
"vis(repin,repout)\n",
"print((repin>>repout).symmetric_basis().shape)"
"print(f\"Basis matrix of shape {(repin>>repout).symmetric_basis().shape}\")"
]
},
{
Expand Down Expand Up @@ -807,7 +806,7 @@
"v = np.random.randn(P.shape[-1])\n",
"v = P@v\n",
"plt.imshow(v.reshape(repout.size(),repin.size()))\n",
"plt.axis('off')"
"plt.axis('off');"
]
},
{
Expand Down
13 changes: 6 additions & 7 deletions docs/notebooks/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ G = Z(6)
repin = V(G)
repout = V(G)
conv_basis = (repin>>repout).symmetric_basis()
print(conv_basis.shape)
print(f"Conv basis has shape {conv_basis.shape}")
```

While we provide an orthogonal basis, these bases are not always easy to make sense of as an array of numbers (any rotation of an orthogonal basis is still an orthogonal basis)
Expand All @@ -138,8 +138,8 @@ def vis_basis(basis,shape,cluster=True):
plt.axis('off')
def vis(repin,repout,cluster=True):
Q = (repin>>repout).symmetric_basis()
vis_basis(Q,(repout.size(),repin.size()),cluster)
Q = (repin>>repout).symmetric_basis() # compute the equivariant basis
vis_basis(Q,(repout.size(),repin.size()),cluster) # visualize it
```

Our convolutional basis is the familiar (circulant) convolution matrix.
Expand Down Expand Up @@ -171,7 +171,7 @@ What about graphs, which are composed both of sets as well as adjacency matrices
repin = V(S(6))**2
repout = V(S(6))**2
vis(repin,repout)
print((repin>>repout).symmetric_basis().shape)
print(f"Basis matrix of shape {(repin>>repout).symmetric_basis().shape}")
```

How about the continuous $2$D rotation group $SO(3)$? It's well known that the only equivariant object for the vector space $V^{\otimes 3}$ is the Levi-Civita symbol $\epsilon_{ijk}$. Since the values are both $0$, positive, and negative (leading to more than `Q.shape[-1]` clusters) we disable the clustering.
Expand Down Expand Up @@ -213,9 +213,8 @@ How about maps from graphs to sets? Lets say a graph consists of one node featur
W = V(S(6))
repin = W+W**2 # (one set feature and one edge feature)
repout = W # (one set feature)
vis(repin,repout)
print((repin>>repout).symmetric_basis().shape)
print(f"Basis matrix of shape {(repin>>repout).symmetric_basis().shape}")
```

Representations that have many copies or multiplicity of a given representation type, such as for the many channels in a neural network, are simply examples of the $\otimes$ operator (`+` in python). The `rep.symmetric_basis()` and `rep.symmetric_projector()` can return lazy matrices $Q$ and $P=QQ^T$ when the representations are composite (or when the representation is specified lazily). [implementation change is making this much slower than normal, using smaller values]
Expand All @@ -242,7 +241,7 @@ P =rep_map.symmetric_projector()
v = np.random.randn(P.shape[-1])
v = P@v
plt.imshow(v.reshape(repout.size(),repin.size()))
plt.axis('off')
plt.axis('off');
```

```{code-cell} ipython3
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pytest-xdist
jupytext
# Packages used for notebook execution
matplotlib
. # install emlp itself from current directory.
#. # install emlp itself from current directory.

0 comments on commit a4c4be0

Please sign in to comment.