forked from PrincetonUniversity/PsyNeuLink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: autogenerate animations, compare with CI (PrincetonUniversity#2104
) Generating animations used in the docs (currently only Composition_XOR_animation.gif referenced in composition.py) allows changes to be monitored with the docs-compare CI. Originally mentioned in PrincetonUniversity#1861, to allow updating pillow requirement
- Loading branch information
Showing
6 changed files
with
96 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,14 +94,14 @@ jobs: | |
run: git tag 'v999.999.999.999' | ||
|
||
- name: Build Documentation | ||
run: sphinx-build -b html -aE -j auto docs/source pnl-html | ||
run: make -C docs/ html -e SPHINXOPTS="-aE -j auto" | ||
|
||
- name: Upload Documentation | ||
uses: actions/[email protected] | ||
with: | ||
name: Documentation-${{matrix.pnl-version}}-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }} | ||
retention-days: 1 | ||
path: pnl-html | ||
path: docs/build/html | ||
|
||
docs-deploy: | ||
strategy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,13 +67,13 @@ jobs: | |
run: git tag 'v999.999.999.999' | ||
|
||
- name: Build docs | ||
run: sphinx-build -b html -aE -j auto docs/source pnl-html | ||
run: make -C docs/ html -e SPHINXOPTS="-aE -j auto" | ||
|
||
- name: Upload generated docs | ||
uses: actions/[email protected] | ||
with: | ||
name: docs-${{ matrix.pnl-version }}-${{ matrix.os }}-${{ matrix.python-version }} | ||
path: pnl-html | ||
path: docs/build/html | ||
retention-days: 1 | ||
|
||
docs-compare: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import argparse | ||
import os | ||
|
||
import numpy as np | ||
import psyneulink as pnl | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-d", | ||
"--directory", | ||
type=str, | ||
default=os.path.join(os.path.dirname(__file__), "..", "_images"), | ||
help="Path to store generated animations", | ||
) | ||
args = parser.parse_args() | ||
|
||
|
||
# Based on tests/composition/test_learning.py::TestLearningPathwayMethods::test_run_no_targets | ||
def composition_xor_animation(): | ||
in_to_hidden_matrix = np.random.rand(2, 10) | ||
hidden_to_out_matrix = np.random.rand(10, 1) | ||
|
||
inp = pnl.TransferMechanism(name="Input", default_variable=np.zeros(2)) | ||
|
||
hidden = pnl.TransferMechanism( | ||
name="Hidden", default_variable=np.zeros(10), function=pnl.Logistic() | ||
) | ||
|
||
output = pnl.TransferMechanism( | ||
name="Output", default_variable=np.zeros(1), function=pnl.Logistic() | ||
) | ||
|
||
in_to_hidden = pnl.MappingProjection( | ||
name="Input Weights", | ||
matrix=in_to_hidden_matrix.copy(), | ||
sender=inp, | ||
receiver=hidden, | ||
) | ||
|
||
hidden_to_out = pnl.MappingProjection( | ||
name="Output Weights", | ||
matrix=hidden_to_out_matrix.copy(), | ||
sender=hidden, | ||
receiver=output, | ||
) | ||
|
||
xor_comp = pnl.Composition() | ||
|
||
xor_comp.add_backpropagation_learning_pathway( | ||
[inp, in_to_hidden, hidden, hidden_to_out, output], | ||
learning_rate=10, | ||
) | ||
xor_inputs = np.array([[0, 0], [0, 1], [1, 0], [1, 1]]) | ||
xor_comp.learn( | ||
inputs={inp: xor_inputs}, | ||
animate={ | ||
pnl.SHOW_LEARNING: True, | ||
pnl.MOVIE_DIR: args.directory, | ||
pnl.MOVIE_NAME: "Composition_XOR_animation", | ||
}, | ||
) | ||
|
||
|
||
composition_xor_animation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters