diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d9503223..78ecc3506 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,12 +59,19 @@ jobs: python -m pytest -m coremdf tests/ - name: Install optional dependencies - run: python -m pip install .[all] + run: | + python -m pip install .[all] - name: Version info for optional installed packages run: | pip list + - name: Install graphviz + if: ${{ matrix.runs-on != 'windows-latest' }} + run: | + if [[ ${{ matrix.runs-on }} == *"macos"* ]]; then brew install graphviz ; fi + if [[ ${{ matrix.runs-on }} == *"ubuntu"* ]]; then sudo apt install graphviz ; fi + - name: Test interface ACT-R if: ${{ matrix.python-version != '3.10' || matrix.runs-on != 'windows-latest' }} run: | @@ -88,8 +95,6 @@ jobs: - name: Test interface TensorFlow linux/mac if: ${{ matrix.runs-on != 'windows-latest' }} run: | - if [[ ${{ matrix.runs-on }} == *"macos"* ]]; then brew install graphviz ; fi - if [[ ${{ matrix.runs-on }} == *"ubuntu"* ]]; then sudo apt install graphviz ; fi dot -V python -m pytest -v -m "tensorflow" tests/ diff --git a/.gitignore b/.gitignore index bf7ae85d8..983da1633 100644 --- a/.gitignore +++ b/.gitignore @@ -276,3 +276,5 @@ Thumbs.db #thumbnail cache on Windows /examples/MDF/NLP/TestNLP /examples/MDF/conditions/composite_example /examples/NeuroML/arm64 +/examples/MDF/RNN/iaf.net +/examples/MDF/RNN/iaf.net2 diff --git a/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png b/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png index 8e44ebb40..88508848f 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png and b/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/abcd.png b/docs/sphinx/source/api/export_format/MDF/images/abcd.png index 3e1b02fa0..3d02389f9 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/abcd.png and b/docs/sphinx/source/api/export_format/MDF/images/abcd.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/abcd_3.png b/docs/sphinx/source/api/export_format/MDF/images/abcd_3.png index 2a15ca11e..2a77534f5 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/abcd_3.png and b/docs/sphinx/source/api/export_format/MDF/images/abcd_3.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/arrays.png b/docs/sphinx/source/api/export_format/MDF/images/arrays.png index 2d335c77c..3c3b1dd69 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/arrays.png and b/docs/sphinx/source/api/export_format/MDF/images/arrays.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/params_funcs.png b/docs/sphinx/source/api/export_format/MDF/images/params_funcs.png index 9d9d0365d..d9921eb15 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/params_funcs.png and b/docs/sphinx/source/api/export_format/MDF/images/params_funcs.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/simple.png b/docs/sphinx/source/api/export_format/MDF/images/simple.png index ccda3c0df..7d2983f5c 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/simple.png and b/docs/sphinx/source/api/export_format/MDF/images/simple.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/simple_3.png b/docs/sphinx/source/api/export_format/MDF/images/simple_3.png index 8275edceb..fa64c3c01 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/simple_3.png and b/docs/sphinx/source/api/export_format/MDF/images/simple_3.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/states.png b/docs/sphinx/source/api/export_format/MDF/images/states.png index a9d1fef26..ce5db8c5e 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/states.png and b/docs/sphinx/source/api/export_format/MDF/images/states.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/ABCD.1.mdf.png b/docs/sphinx/source/api/export_format/NeuroML/ABCD.1.mdf.png index 0e2abb4ce..2972c1bdd 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/ABCD.1.mdf.png and b/docs/sphinx/source/api/export_format/NeuroML/ABCD.1.mdf.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png b/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png index e804b226f..2e5ce54c4 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png and b/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/ABCD.nmllite.png b/docs/sphinx/source/api/export_format/NeuroML/ABCD.nmllite.png index 0faa617a1..351afe024 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/ABCD.nmllite.png and b/docs/sphinx/source/api/export_format/NeuroML/ABCD.nmllite.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/FN.gv.png b/docs/sphinx/source/api/export_format/NeuroML/FN.gv.png index 32ae53a56..c6d61be82 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/FN.gv.png and b/docs/sphinx/source/api/export_format/NeuroML/FN.gv.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/FNmulti.png b/docs/sphinx/source/api/export_format/NeuroML/FNmulti.png index 178ac75f9..c4bfab28d 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/FNmulti.png and b/docs/sphinx/source/api/export_format/NeuroML/FNmulti.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/Izh.png b/docs/sphinx/source/api/export_format/NeuroML/Izh.png index 006a2ce49..88f497920 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/Izh.png and b/docs/sphinx/source/api/export_format/NeuroML/Izh.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/IzhikevichTest.gv.png b/docs/sphinx/source/api/export_format/NeuroML/IzhikevichTest.gv.png index 953b8c821..71a39af4a 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/IzhikevichTest.gv.png and b/docs/sphinx/source/api/export_format/NeuroML/IzhikevichTest.gv.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png index 3f3bd62bb..0906f4863 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png and b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png index eba8406ef..2b558ab55 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png and b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png index 2dbcc2b52..51b9a82ce 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png and b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/MDFFNrun.multi.png b/docs/sphinx/source/api/export_format/NeuroML/MDFFNrun.multi.png index 9e31dec82..0ca380dbd 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/MDFFNrun.multi.png and b/docs/sphinx/source/api/export_format/NeuroML/MDFFNrun.multi.png differ diff --git a/docs/sphinx/source/api/export_format/ONNX/ab.png b/docs/sphinx/source/api/export_format/ONNX/ab.png index 62e7ceb59..7b76243db 100644 Binary files a/docs/sphinx/source/api/export_format/ONNX/ab.png and b/docs/sphinx/source/api/export_format/ONNX/ab.png differ diff --git a/docs/sphinx/source/api/export_format/ONNX/simple_ab.py b/docs/sphinx/source/api/export_format/ONNX/simple_ab.py index da06f6f34..105dbac50 100644 --- a/docs/sphinx/source/api/export_format/ONNX/simple_ab.py +++ b/docs/sphinx/source/api/export_format/ONNX/simple_ab.py @@ -7,6 +7,7 @@ import torch import onnx import sys +import os from modeci_mdf.interfaces.onnx import onnx_to_mdf @@ -80,7 +81,9 @@ def main(): view_on_render=False, level=3, filename_root="ab", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) if "-run" in sys.argv: verbose = True diff --git a/docs/sphinx/source/api/export_format/ONNX/simple_abc.py b/docs/sphinx/source/api/export_format/ONNX/simple_abc.py index 1adbdfc25..ecb57769e 100644 --- a/docs/sphinx/source/api/export_format/ONNX/simple_abc.py +++ b/docs/sphinx/source/api/export_format/ONNX/simple_abc.py @@ -6,6 +6,7 @@ """ import torch import onnx +import os from modeci_mdf.interfaces.onnx import onnx_to_mdf @@ -82,7 +83,9 @@ def main(): view_on_render=False, level=3, filename_root="abc", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/docs/sphinx/source/api/export_format/PyTorch/inception.png b/docs/sphinx/source/api/export_format/PyTorch/inception.png index 828201e86..ed468c27f 100644 Binary files a/docs/sphinx/source/api/export_format/PyTorch/inception.png and b/docs/sphinx/source/api/export_format/PyTorch/inception.png differ diff --git a/docs/sphinx/source/api/export_format/PyTorch/mlp_pure_mdf.png b/docs/sphinx/source/api/export_format/PyTorch/mlp_pure_mdf.png index df5d21ce8..4267ec857 100644 Binary files a/docs/sphinx/source/api/export_format/PyTorch/mlp_pure_mdf.png and b/docs/sphinx/source/api/export_format/PyTorch/mlp_pure_mdf.png differ diff --git a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.1.png b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.1.png index 90fa4a086..6e28015c1 100644 Binary files a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.1.png and b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.1.png differ diff --git a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.png b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.png index 6e94fccaa..3749fcb67 100644 Binary files a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.png and b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf.png differ diff --git a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png index 599c2049c..561d0b870 100644 Binary files a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png and b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png differ diff --git a/examples/ACT-R/addition.json b/examples/ACT-R/addition.json index c9d69859d..1414d18d8 100644 --- a/examples/ACT-R/addition.json +++ b/examples/ACT-R/addition.json @@ -1,7 +1,7 @@ { "addition": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "addition_graph": { "nodes": { diff --git a/examples/ACT-R/addition.yaml b/examples/ACT-R/addition.yaml index fba4148da..b4c2d84a7 100644 --- a/examples/ACT-R/addition.yaml +++ b/examples/ACT-R/addition.yaml @@ -1,6 +1,6 @@ addition: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: addition_graph: nodes: diff --git a/examples/ACT-R/count.json b/examples/ACT-R/count.json index 4cca9a06b..5888b29f9 100644 --- a/examples/ACT-R/count.json +++ b/examples/ACT-R/count.json @@ -1,7 +1,7 @@ { "count": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "count_graph": { "nodes": { diff --git a/examples/ACT-R/count.yaml b/examples/ACT-R/count.yaml index cfda39caf..01b981055 100644 --- a/examples/ACT-R/count.yaml +++ b/examples/ACT-R/count.yaml @@ -1,6 +1,6 @@ count: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: count_graph: nodes: diff --git a/examples/MDF/ABCD.json b/examples/MDF/ABCD.json index 9a5b5c9e1..1750f4c8c 100644 --- a/examples/MDF/ABCD.json +++ b/examples/MDF/ABCD.json @@ -1,7 +1,7 @@ { "ABCD": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "abcd_example": { "nodes": { diff --git a/examples/MDF/ABCD.yaml b/examples/MDF/ABCD.yaml index 277194287..2df48661f 100644 --- a/examples/MDF/ABCD.yaml +++ b/examples/MDF/ABCD.yaml @@ -1,6 +1,6 @@ ABCD: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: abcd_example: nodes: diff --git a/examples/MDF/Arrays.json b/examples/MDF/Arrays.json index 23dfaec89..65f6e4d95 100644 --- a/examples/MDF/Arrays.json +++ b/examples/MDF/Arrays.json @@ -1,7 +1,7 @@ { "Arrays": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "array_example": { "nodes": { @@ -28,7 +28,12 @@ }, "middle_node": { "input_ports": { - "input_port1": {} + "input_port1": { + "shape": [ + 2, + 2 + ] + } }, "parameters": { "slope": { diff --git a/examples/MDF/Arrays.yaml b/examples/MDF/Arrays.yaml index e58536006..1a9094fd5 100644 --- a/examples/MDF/Arrays.yaml +++ b/examples/MDF/Arrays.yaml @@ -1,6 +1,6 @@ Arrays: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: array_example: nodes: @@ -17,7 +17,10 @@ Arrays: value: input_level middle_node: input_ports: - input_port1: {} + input_port1: + shape: + - 2 + - 2 parameters: slope: value: 0.5 diff --git a/examples/MDF/ParametersFunctions.json b/examples/MDF/ParametersFunctions.json index 9189428b9..36a486558 100644 --- a/examples/MDF/ParametersFunctions.json +++ b/examples/MDF/ParametersFunctions.json @@ -1,7 +1,7 @@ { "ParametersFunctions": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "params_funcs_example": { "nodes": { diff --git a/examples/MDF/ParametersFunctions.yaml b/examples/MDF/ParametersFunctions.yaml index e18744055..03538bb9f 100644 --- a/examples/MDF/ParametersFunctions.yaml +++ b/examples/MDF/ParametersFunctions.yaml @@ -1,6 +1,6 @@ ParametersFunctions: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: params_funcs_example: nodes: diff --git a/examples/MDF/RNN/IAF_net.json b/examples/MDF/RNN/IAF_net.json index ab93415c4..7dd1d7394 100644 --- a/examples/MDF/RNN/IAF_net.json +++ b/examples/MDF/RNN/IAF_net.json @@ -1,11 +1,11 @@ { "IAF_net": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "iaf_example": { "nodes": { - "input_node": { + "current_input_node": { "parameters": { "time": { "default_initial_value": 0, @@ -34,7 +34,7 @@ "conditions": [ { "id": "on", - "test": "time > start and time < start + duration", + "test": "time > start", "value": "amplitude" }, { @@ -46,20 +46,20 @@ } }, "output_ports": { - "out_port": { + "current_output": { "value": "level" } } }, "pre": { "input_ports": { - "current_input": {}, - "spike_input": {} + "current_input": { + "shape": [ + 8 + ] + } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ -54.67038134416407, @@ -74,14 +74,14 @@ }, "erev": { "value": [ - -70.0, - -70.0, - -70.0, - -70.0, - -70.0, - -70.0, - -70.0, - -70.0 + -70, + -70, + -70, + -70, + -70, + -70, + -70, + -70 ] }, "tau": { @@ -89,25 +89,14 @@ }, "thresh": { "value": [ - -20.0, - -20.0, - -20.0, - -20.0, - -20.0, - -20.0, - -20.0, - -20.0 - ] - }, - "syn_i": { - "default_initial_value": "0", - "time_derivative": "-1 * syn_i", - "conditions": [ - { - "id": "spike_detected", - "test": "spike_input > 0", - "value": "spike_input" - } + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 ] }, "spiking": { @@ -127,7 +116,7 @@ }, "v": { "default_initial_value": "v0", - "time_derivative": "-1 * (v-erev)/tau + syn_i + current_input", + "time_derivative": "-1 * (v-erev)/tau + current_input", "conditions": [ { "id": "reset", @@ -138,45 +127,45 @@ } }, "output_ports": { - "out_port_v": { + "v_output": { "value": "v" }, - "out_port_spiking": { + "spiking_output": { "value": "spiking" } } }, "post": { "input_ports": { - "current_input": {}, - "spike_input": {} + "current_input": { + "shape": [ + 8 + ] + } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ - -66.33818705180137, - -67.71174060622624, - -69.70762439026181, - -60.26496918790483, - -50.70196878167569, - -68.70875438045628, - -59.178236288977395, - -60.68202881983381 + -54.67038134416407, + -65.26380449273765, + -69.3837195654678, + -54.224545655274326, + -63.07822068805754, + -57.53437049921663, + -57.6836860979277, + -67.02890722583425 ] }, "erev": { "value": [ - -70.0, - -70.0, - -70.0, - -70.0, - -70.0, - -70.0, - -70.0, - -70.0 + -70, + -70, + -70, + -70, + -70, + -70, + -70, + -70 ] }, "tau": { @@ -184,25 +173,14 @@ }, "thresh": { "value": [ - -20.0, - -20.0, - -20.0, - -20.0, - -20.0, - -20.0, - -20.0, - -20.0 - ] - }, - "syn_i": { - "default_initial_value": "0", - "time_derivative": "-1 * syn_i", - "conditions": [ - { - "id": "spike_detected", - "test": "spike_input > 0", - "value": "spike_input" - } + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 ] }, "spiking": { @@ -222,7 +200,7 @@ }, "v": { "default_initial_value": "v0", - "time_derivative": "-1 * (v-erev)/tau + syn_i + current_input", + "time_derivative": "-1 * (v-erev)/tau + current_input", "conditions": [ { "id": "reset", @@ -233,33 +211,154 @@ } }, "output_ports": { - "out_port_v": { + "v_output": { "value": "v" }, - "out_port_spiking": { + "spiking_output": { "value": "spiking" } } + }, + "syn_post": { + "input_ports": { + "spike_input": { + "shape": [ + 8 + ] + } + }, + "parameters": { + "syn_tau": { + "value": 10 + }, + "spike_weights": { + "value": [ + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ], + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ], + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ], + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ], + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ], + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ], + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ], + [ + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0 + ] + ] + }, + "weighted_spike": { + "function": "MatMul", + "args": { + "A": "spike_weights", + "B": "spike_input" + } + }, + "syn_i": { + "default_initial_value": "0", + "time_derivative": "-1 * syn_i", + "conditions": [ + { + "id": "spike_detected", + "test": "spike_input > 0", + "value": "weighted_spike" + } + ] + } + }, + "output_ports": { + "current_output": { + "value": "syn_i" + } + } } }, "edges": { "input_edge": { - "sender": "input_node", + "sender": "current_input_node", "receiver": "pre", - "sender_port": "out_port", - "receiver_port": "current_input", - "parameters": { - "weight": 1 - } + "sender_port": "current_output", + "receiver_port": "current_input" + }, + "post_internal_edge": { + "sender": "syn_post", + "receiver": "post", + "sender_port": "current_output", + "receiver_port": "current_input" }, "syn_edge": { "sender": "pre", - "receiver": "post", - "sender_port": "out_port_spiking", - "receiver_port": "spike_input", - "parameters": { - "weight": 40 - } + "receiver": "syn_post", + "sender_port": "spiking_output", + "receiver_port": "spike_input" } } } diff --git a/examples/MDF/RNN/IAF_net.yaml b/examples/MDF/RNN/IAF_net.yaml index 765c1f85e..7a18e31cb 100644 --- a/examples/MDF/RNN/IAF_net.yaml +++ b/examples/MDF/RNN/IAF_net.yaml @@ -1,10 +1,10 @@ IAF_net: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: iaf_example: nodes: - input_node: + current_input_node: parameters: time: default_initial_value: 0 @@ -27,21 +27,20 @@ IAF_net: value: 0 conditions: - id: 'on' - test: time > start and time < start + duration + test: time > start value: amplitude - id: 'off' test: time > start + duration value: amplitude*0 output_ports: - out_port: + current_output: value: level pre: input_ports: - current_input: {} - spike_input: {} + current_input: + shape: + - 8 parameters: - syn_tau: - value: 10 v0: value: - -54.67038134416407 @@ -54,33 +53,26 @@ IAF_net: - -67.02890722583425 erev: value: - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 tau: value: 10.0 thresh: value: - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - syn_i: - default_initial_value: '0' - time_derivative: -1 * syn_i - conditions: - - id: spike_detected - test: spike_input > 0 - value: spike_input + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 spiking: default_initial_value: '0' conditions: @@ -92,62 +84,54 @@ IAF_net: value: '0' v: default_initial_value: v0 - time_derivative: -1 * (v-erev)/tau + syn_i + current_input + time_derivative: -1 * (v-erev)/tau + current_input conditions: - id: reset test: v > thresh value: erev output_ports: - out_port_v: + v_output: value: v - out_port_spiking: + spiking_output: value: spiking post: input_ports: - current_input: {} - spike_input: {} + current_input: + shape: + - 8 parameters: - syn_tau: - value: 10 v0: value: - - -66.33818705180137 - - -67.71174060622624 - - -69.70762439026181 - - -60.26496918790483 - - -50.70196878167569 - - -68.70875438045628 - - -59.178236288977395 - - -60.68202881983381 + - -54.67038134416407 + - -65.26380449273765 + - -69.3837195654678 + - -54.224545655274326 + - -63.07822068805754 + - -57.53437049921663 + - -57.6836860979277 + - -67.02890722583425 erev: value: - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 - - -70.0 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 tau: value: 10.0 thresh: value: - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - - -20.0 - syn_i: - default_initial_value: '0' - time_derivative: -1 * syn_i - conditions: - - id: spike_detected - test: spike_input > 0 - value: spike_input + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 spiking: default_initial_value: '0' conditions: @@ -159,28 +143,118 @@ IAF_net: value: '0' v: default_initial_value: v0 - time_derivative: -1 * (v-erev)/tau + syn_i + current_input + time_derivative: -1 * (v-erev)/tau + current_input conditions: - id: reset test: v > thresh value: erev output_ports: - out_port_v: + v_output: value: v - out_port_spiking: + spiking_output: value: spiking + syn_post: + input_ports: + spike_input: + shape: + - 8 + parameters: + syn_tau: + value: 10 + spike_weights: + value: + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + - 40.0 + weighted_spike: + function: MatMul + args: + A: spike_weights + B: spike_input + syn_i: + default_initial_value: '0' + time_derivative: -1 * syn_i + conditions: + - id: spike_detected + test: spike_input > 0 + value: weighted_spike + output_ports: + current_output: + value: syn_i edges: input_edge: - sender: input_node + sender: current_input_node receiver: pre - sender_port: out_port + sender_port: current_output + receiver_port: current_input + post_internal_edge: + sender: syn_post + receiver: post + sender_port: current_output receiver_port: current_input - parameters: - weight: 1 syn_edge: sender: pre - receiver: post - sender_port: out_port_spiking + receiver: syn_post + sender_port: spiking_output receiver_port: spike_input - parameters: - weight: 40 diff --git a/examples/MDF/RNN/IAF_net2.json b/examples/MDF/RNN/IAF_net2.json new file mode 100644 index 000000000..1402dd637 --- /dev/null +++ b/examples/MDF/RNN/IAF_net2.json @@ -0,0 +1,376 @@ +{ + "IAF_net2": { + "format": "ModECI MDF v0.4", + "generating_application": "Python modeci-mdf v0.4.6", + "graphs": { + "iaf_example": { + "nodes": { + "current_input_node": { + "parameters": { + "time": { + "default_initial_value": 0, + "time_derivative": "1" + }, + "start": { + "value": [ + 10, + 20, + 30, + 40, + 50, + 60, + 70, + 80 + ] + }, + "duration": { + "value": [ + 5.0, + 5.0, + 5.0, + 5.0, + 5.0, + 5.0, + 5.0, + 5.0 + ] + }, + "amplitude": { + "value": 15 + }, + "level": { + "value": 0, + "conditions": [ + { + "id": "on", + "test": "time > start", + "value": "amplitude" + }, + { + "id": "off", + "test": "time > start + duration", + "value": "amplitude*0" + } + ] + } + }, + "output_ports": { + "current_output": { + "value": "level" + } + } + }, + "pre": { + "input_ports": { + "current_input": { + "shape": [ + 8 + ] + } + }, + "parameters": { + "v0": { + "value": [ + -70, + -70, + -70, + -70, + -70, + -70, + -70, + -70 + ] + }, + "erev": { + "value": [ + -70, + -70, + -70, + -70, + -70, + -70, + -70, + -70 + ] + }, + "tau": { + "value": 10.0 + }, + "thresh": { + "value": [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ] + }, + "spiking": { + "default_initial_value": "0", + "conditions": [ + { + "id": "is_spiking", + "test": "v >= thresh", + "value": "1" + }, + { + "id": "not_spiking", + "test": "v < thresh", + "value": "0" + } + ] + }, + "v": { + "default_initial_value": "v0", + "time_derivative": "-1 * (v-erev)/tau + current_input", + "conditions": [ + { + "id": "reset", + "test": "v > thresh", + "value": "erev" + } + ] + } + }, + "output_ports": { + "v_output": { + "value": "v" + }, + "spiking_output": { + "value": "spiking" + } + } + }, + "post": { + "input_ports": { + "current_input": { + "shape": [ + 8 + ] + } + }, + "parameters": { + "v0": { + "value": [ + -70, + -70, + -70, + -70, + -70, + -70, + -70, + -70 + ] + }, + "erev": { + "value": [ + -70, + -70, + -70, + -70, + -70, + -70, + -70, + -70 + ] + }, + "tau": { + "value": 1 + }, + "thresh": { + "value": [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ] + }, + "spiking": { + "default_initial_value": "0", + "conditions": [ + { + "id": "is_spiking", + "test": "v >= thresh", + "value": "1" + }, + { + "id": "not_spiking", + "test": "v < thresh", + "value": "0" + } + ] + }, + "v": { + "default_initial_value": "v0", + "time_derivative": "-1 * (v-erev)/tau + current_input", + "conditions": [ + { + "id": "reset", + "test": "v > thresh", + "value": "erev" + } + ] + } + }, + "output_ports": { + "v_output": { + "value": "v" + }, + "spiking_output": { + "value": "spiking" + } + } + }, + "syn_post": { + "input_ports": { + "spike_input": { + "shape": [ + 8 + ] + } + }, + "parameters": { + "syn_tau": { + "value": 10 + }, + "spike_weights": { + "value": [ + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 5.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 6.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 7.0 + ] + ] + }, + "weighted_spike": { + "function": "MatMul", + "args": { + "A": "spike_weights", + "B": "spike_input" + } + }, + "syn_i": { + "default_initial_value": "0", + "time_derivative": "-1 * syn_i", + "conditions": [ + { + "id": "spike_detected", + "test": "spike_input > 0", + "value": "weighted_spike" + } + ] + } + }, + "output_ports": { + "current_output": { + "value": "syn_i" + } + } + } + }, + "edges": { + "input_edge": { + "sender": "current_input_node", + "receiver": "pre", + "sender_port": "current_output", + "receiver_port": "current_input" + }, + "post_internal_edge": { + "sender": "syn_post", + "receiver": "post", + "sender_port": "current_output", + "receiver_port": "current_input" + }, + "syn_edge": { + "sender": "pre", + "receiver": "syn_post", + "sender_port": "spiking_output", + "receiver_port": "spike_input" + } + } + } + } + } +} diff --git a/examples/MDF/RNN/IAF_net2.yaml b/examples/MDF/RNN/IAF_net2.yaml new file mode 100644 index 000000000..6972a75c0 --- /dev/null +++ b/examples/MDF/RNN/IAF_net2.yaml @@ -0,0 +1,268 @@ +IAF_net2: + format: ModECI MDF v0.4 + generating_application: Python modeci-mdf v0.4.6 + graphs: + iaf_example: + nodes: + current_input_node: + parameters: + time: + default_initial_value: 0 + time_derivative: '1' + start: + value: + - 10 + - 20 + - 30 + - 40 + - 50 + - 60 + - 70 + - 80 + duration: + value: + - 5.0 + - 5.0 + - 5.0 + - 5.0 + - 5.0 + - 5.0 + - 5.0 + - 5.0 + amplitude: + value: 15 + level: + value: 0 + conditions: + - id: 'on' + test: time > start + value: amplitude + - id: 'off' + test: time > start + duration + value: amplitude*0 + output_ports: + current_output: + value: level + pre: + input_ports: + current_input: + shape: + - 8 + parameters: + v0: + value: + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + erev: + value: + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + tau: + value: 10.0 + thresh: + value: + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + spiking: + default_initial_value: '0' + conditions: + - id: is_spiking + test: v >= thresh + value: '1' + - id: not_spiking + test: v < thresh + value: '0' + v: + default_initial_value: v0 + time_derivative: -1 * (v-erev)/tau + current_input + conditions: + - id: reset + test: v > thresh + value: erev + output_ports: + v_output: + value: v + spiking_output: + value: spiking + post: + input_ports: + current_input: + shape: + - 8 + parameters: + v0: + value: + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + erev: + value: + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + - -70 + tau: + value: 1 + thresh: + value: + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + - -20 + spiking: + default_initial_value: '0' + conditions: + - id: is_spiking + test: v >= thresh + value: '1' + - id: not_spiking + test: v < thresh + value: '0' + v: + default_initial_value: v0 + time_derivative: -1 * (v-erev)/tau + current_input + conditions: + - id: reset + test: v > thresh + value: erev + output_ports: + v_output: + value: v + spiking_output: + value: spiking + syn_post: + input_ports: + spike_input: + shape: + - 8 + parameters: + syn_tau: + value: 10 + spike_weights: + value: + - - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - - 0.0 + - 1.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - - 0.0 + - 0.0 + - 2.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - - 0.0 + - 0.0 + - 0.0 + - 3.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 4.0 + - 0.0 + - 0.0 + - 0.0 + - - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 5.0 + - 0.0 + - 0.0 + - - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 6.0 + - 0.0 + - - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 7.0 + weighted_spike: + function: MatMul + args: + A: spike_weights + B: spike_input + syn_i: + default_initial_value: '0' + time_derivative: -1 * syn_i + conditions: + - id: spike_detected + test: spike_input > 0 + value: weighted_spike + output_ports: + current_output: + value: syn_i + edges: + input_edge: + sender: current_input_node + receiver: pre + sender_port: current_output + receiver_port: current_input + post_internal_edge: + sender: syn_post + receiver: post + sender_port: current_output + receiver_port: current_input + syn_edge: + sender: pre + receiver: syn_post + sender_port: spiking_output + receiver_port: spike_input diff --git a/examples/MDF/RNN/IAFs.json b/examples/MDF/RNN/IAFs.json index 54bcd1607..b413bf84a 100644 --- a/examples/MDF/RNN/IAFs.json +++ b/examples/MDF/RNN/IAFs.json @@ -1,11 +1,11 @@ { "IAFs": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "iaf_example": { "nodes": { - "input_node": { + "current_input_node": { "parameters": { "time": { "default_initial_value": 0, @@ -25,7 +25,7 @@ "conditions": [ { "id": "on", - "test": "time > start and time < start + duration", + "test": "time > start", "value": "amplitude" }, { @@ -37,41 +37,36 @@ } }, "output_ports": { - "out_port": { + "current_output": { "value": "level" } } }, "pre": { "input_ports": { - "current_input": {}, - "spike_input": {} + "current_input": { + "shape": [ + 1 + ] + } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { - "value": -60 + "value": [ + -60 + ] }, "erev": { - "value": -70 + "value": [ + -70 + ] }, "tau": { "value": 10.0 }, "thresh": { - "value": -20.0 - }, - "syn_i": { - "default_initial_value": "0", - "time_derivative": "-1 * syn_i", - "conditions": [ - { - "id": "spike_detected", - "test": "spike_input > 0", - "value": "spike_input" - } + "value": [ + -20 ] }, "spiking": { @@ -91,7 +86,7 @@ }, "v": { "default_initial_value": "v0", - "time_derivative": "-1 * (v-erev)/tau + syn_i + current_input", + "time_derivative": "-1 * (v-erev)/tau + current_input", "conditions": [ { "id": "reset", @@ -102,44 +97,39 @@ } }, "output_ports": { - "out_port_v": { + "v_output": { "value": "v" }, - "out_port_spiking": { + "spiking_output": { "value": "spiking" } } }, "post": { "input_ports": { - "current_input": {}, - "spike_input": {} + "current_input": { + "shape": [ + 1 + ] + } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { - "value": -60 + "value": [ + -60 + ] }, "erev": { - "value": -70 + "value": [ + -70 + ] }, "tau": { "value": 10.0 }, "thresh": { - "value": -20.0 - }, - "syn_i": { - "default_initial_value": "0", - "time_derivative": "-1 * syn_i", - "conditions": [ - { - "id": "spike_detected", - "test": "spike_input > 0", - "value": "spike_input" - } + "value": [ + -20 ] }, "spiking": { @@ -159,7 +149,7 @@ }, "v": { "default_initial_value": "v0", - "time_derivative": "-1 * (v-erev)/tau + syn_i + current_input", + "time_derivative": "-1 * (v-erev)/tau + current_input", "conditions": [ { "id": "reset", @@ -170,33 +160,75 @@ } }, "output_ports": { - "out_port_v": { + "v_output": { "value": "v" }, - "out_port_spiking": { + "spiking_output": { "value": "spiking" } } + }, + "syn_post": { + "input_ports": { + "spike_input": { + "shape": [ + 1 + ] + } + }, + "parameters": { + "syn_tau": { + "value": 10 + }, + "spike_weights": { + "value": [ + 40 + ] + }, + "weighted_spike": { + "function": "MatMul", + "args": { + "A": "spike_weights", + "B": "spike_input" + } + }, + "syn_i": { + "default_initial_value": "0", + "time_derivative": "-1 * syn_i", + "conditions": [ + { + "id": "spike_detected", + "test": "spike_input > 0", + "value": "weighted_spike" + } + ] + } + }, + "output_ports": { + "current_output": { + "value": "syn_i" + } + } } }, "edges": { "input_edge": { - "sender": "input_node", + "sender": "current_input_node", "receiver": "pre", - "sender_port": "out_port", - "receiver_port": "current_input", - "parameters": { - "weight": 1 - } + "sender_port": "current_output", + "receiver_port": "current_input" + }, + "post_internal_edge": { + "sender": "syn_post", + "receiver": "post", + "sender_port": "current_output", + "receiver_port": "current_input" }, "syn_edge": { "sender": "pre", - "receiver": "post", - "sender_port": "out_port_spiking", - "receiver_port": "spike_input", - "parameters": { - "weight": 40 - } + "receiver": "syn_post", + "sender_port": "spiking_output", + "receiver_port": "spike_input" } } } diff --git a/examples/MDF/RNN/IAFs.yaml b/examples/MDF/RNN/IAFs.yaml index 1cb9c8392..b7deecbd3 100644 --- a/examples/MDF/RNN/IAFs.yaml +++ b/examples/MDF/RNN/IAFs.yaml @@ -1,10 +1,10 @@ IAFs: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: iaf_example: nodes: - input_node: + current_input_node: parameters: time: default_initial_value: 0 @@ -19,36 +19,31 @@ IAFs: value: 0 conditions: - id: 'on' - test: time > start and time < start + duration + test: time > start value: amplitude - id: 'off' test: time > start + duration value: amplitude*0 output_ports: - out_port: + current_output: value: level pre: input_ports: - current_input: {} - spike_input: {} + current_input: + shape: + - 1 parameters: - syn_tau: - value: 10 v0: - value: -60 + value: + - -60 erev: - value: -70 + value: + - -70 tau: value: 10.0 thresh: - value: -20.0 - syn_i: - default_initial_value: '0' - time_derivative: -1 * syn_i - conditions: - - id: spike_detected - test: spike_input > 0 - value: spike_input + value: + - -20 spiking: default_initial_value: '0' conditions: @@ -60,38 +55,33 @@ IAFs: value: '0' v: default_initial_value: v0 - time_derivative: -1 * (v-erev)/tau + syn_i + current_input + time_derivative: -1 * (v-erev)/tau + current_input conditions: - id: reset test: v > thresh value: erev output_ports: - out_port_v: + v_output: value: v - out_port_spiking: + spiking_output: value: spiking post: input_ports: - current_input: {} - spike_input: {} + current_input: + shape: + - 1 parameters: - syn_tau: - value: 10 v0: - value: -60 + value: + - -60 erev: - value: -70 + value: + - -70 tau: value: 10.0 thresh: - value: -20.0 - syn_i: - default_initial_value: '0' - time_derivative: -1 * syn_i - conditions: - - id: spike_detected - test: spike_input > 0 - value: spike_input + value: + - -20 spiking: default_initial_value: '0' conditions: @@ -103,28 +93,55 @@ IAFs: value: '0' v: default_initial_value: v0 - time_derivative: -1 * (v-erev)/tau + syn_i + current_input + time_derivative: -1 * (v-erev)/tau + current_input conditions: - id: reset test: v > thresh value: erev output_ports: - out_port_v: + v_output: value: v - out_port_spiking: + spiking_output: value: spiking + syn_post: + input_ports: + spike_input: + shape: + - 1 + parameters: + syn_tau: + value: 10 + spike_weights: + value: + - 40 + weighted_spike: + function: MatMul + args: + A: spike_weights + B: spike_input + syn_i: + default_initial_value: '0' + time_derivative: -1 * syn_i + conditions: + - id: spike_detected + test: spike_input > 0 + value: weighted_spike + output_ports: + current_output: + value: syn_i edges: input_edge: - sender: input_node + sender: current_input_node receiver: pre - sender_port: out_port + sender_port: current_output + receiver_port: current_input + post_internal_edge: + sender: syn_post + receiver: post + sender_port: current_output receiver_port: current_input - parameters: - weight: 1 syn_edge: sender: pre - receiver: post - sender_port: out_port_spiking + receiver: syn_post + sender_port: spiking_output receiver_port: spike_input - parameters: - weight: 40 diff --git a/examples/MDF/RNN/IaF.net.run.png b/examples/MDF/RNN/IaF.net.run.png index f02625d57..276c7c23d 100644 Binary files a/examples/MDF/RNN/IaF.net.run.png and b/examples/MDF/RNN/IaF.net.run.png differ diff --git a/examples/MDF/RNN/IaF.net2.run.png b/examples/MDF/RNN/IaF.net2.run.png new file mode 100644 index 000000000..900751bd7 Binary files /dev/null and b/examples/MDF/RNN/IaF.net2.run.png differ diff --git a/examples/MDF/RNN/LEMS_Simiaf_example.png b/examples/MDF/RNN/LEMS_Simiaf_example.png index 7a9be2c69..699299a1a 100644 Binary files a/examples/MDF/RNN/LEMS_Simiaf_example.png and b/examples/MDF/RNN/LEMS_Simiaf_example.png differ diff --git a/examples/MDF/RNN/README.md b/examples/MDF/RNN/README.md index c29d81127..21021628b 100644 --- a/examples/MDF/RNN/README.md +++ b/examples/MDF/RNN/README.md @@ -17,10 +17,14 @@ The script [generate_iaf.py](generate_iaf.py) can be used to generate an example

iaf.png

-To run the network with 1 input, a pre and a post IAF node using the MDF execution engine type `python generate_iaf.py -run`, producing: +To run the network with 1 input, a pre and a post IAF node (each with 1 cell) using the MDF execution engine type `python generate_iaf.py -run`, producing:

IaF.run.png

-To run a network with an array for the state variable v type `python generate_iaf.py -run -net`, producing: +To run a network (2 populations, 8 cells each) with an array for the state variable v, type `python generate_iaf.py -run -net`, producing:

IaF.net.run.png

+ +To run a similar network (2 populations, 8 cells each) with timed pulses into the pre cells, and weighed connections to the post cells, type `python generate_iaf.py -run -net2`, producing: + +

IaF.net2.run.png

diff --git a/examples/MDF/RNN/RNNs.json b/examples/MDF/RNN/RNNs.json index 40008a533..7198adda2 100644 --- a/examples/MDF/RNN/RNNs.json +++ b/examples/MDF/RNN/RNNs.json @@ -1,7 +1,7 @@ { "RNNs": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "rnn_example": { "nodes": { @@ -40,8 +40,16 @@ }, "rnn_node": { "input_ports": { - "ext_input": {}, - "fb_input": {} + "ext_input": { + "shape": [ + 5 + ] + }, + "fb_input": { + "shape": [ + 5 + ] + } }, "parameters": { "M": { @@ -122,7 +130,11 @@ }, "readout_node": { "input_ports": { - "input": {} + "input": { + "shape": [ + 5 + ] + } }, "parameters": { "wr": { diff --git a/examples/MDF/RNN/RNNs.yaml b/examples/MDF/RNN/RNNs.yaml index f8caddce0..2f7235c6d 100644 --- a/examples/MDF/RNN/RNNs.yaml +++ b/examples/MDF/RNN/RNNs.yaml @@ -1,6 +1,6 @@ RNNs: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: rnn_example: nodes: @@ -27,8 +27,12 @@ RNNs: value: t rnn_node: input_ports: - ext_input: {} - fb_input: {} + ext_input: + shape: + - 5 + fb_input: + shape: + - 5 parameters: M: value: @@ -84,7 +88,9 @@ RNNs: value: r readout_node: input_ports: - input: {} + input: + shape: + - 5 parameters: wr: value: diff --git a/examples/MDF/RNN/generate_iaf.py b/examples/MDF/RNN/generate_iaf.py index 162fcb099..42b4ec8fe 100644 --- a/examples/MDF/RNN/generate_iaf.py +++ b/examples/MDF/RNN/generate_iaf.py @@ -4,50 +4,110 @@ from modeci_mdf.mdf import * import sys +import os import numpy import random random.seed(1234) -def create_iaf_node(id, num_cells=1): +def create_current_pulse_node(id, start=20, duration=60, amplitude=10): - ## IAF node... - iaf_node = Node(id) - ip_current = InputPort(id="current_input") - iaf_node.input_ports.append(ip_current) + ## Current input node + current_pulse_node = Node(id=id) - ip_spike = InputPort(id="spike_input") - iaf_node.input_ports.append(ip_spike) - - syn_tau = Parameter(id="syn_tau", value=10) - iaf_node.parameters.append(syn_tau) + t_param = Parameter(id="time", default_initial_value=0, time_derivative="1") + current_pulse_node.parameters.append(t_param) - v0 = Parameter(id="v0", value=-60) + start = Parameter(id="start", value=start) + current_pulse_node.parameters.append(start) - iaf_node.parameters.append(v0) + dur = Parameter(id="duration", value=duration) + current_pulse_node.parameters.append(dur) - erev = Parameter(id="erev", value=-70) - iaf_node.parameters.append(erev) - tau = Parameter(id="tau", value=10.0) - iaf_node.parameters.append(tau) - thresh = Parameter(id="thresh", value=-20.0) - iaf_node.parameters.append(thresh) + amp = Parameter(id="amplitude", value=amplitude) + current_pulse_node.parameters.append(amp) - # v_init = Parameter(id="v_init", value=-30) - # iaf_node.parameters.append(v_init) + level = Parameter(id="level", value=0) - pc = ParameterCondition( - id="spike_detected", test="%s > 0" % ip_spike.id, value=ip_spike.id + level.conditions.append( + ParameterCondition(id="on", test="time > start", value=amp.id) + ) + level.conditions.append( + ParameterCondition( + id="off", test="time > start + duration", value="amplitude*0" + ) ) - syn_i = Parameter( - id="syn_i", - default_initial_value="0", - time_derivative="-1 * syn_i", + current_pulse_node.parameters.append(level) + + op1 = OutputPort(id="current_output", value=level.id) + current_pulse_node.output_ports.append(op1) + + return current_pulse_node + + +def create_iaf_syn_node( + id, num_cells=1, syn_also=True, v0=-60, erev=-70, thresh=-20, tau=10.0, syn_tau=10 +): + + if syn_also: + ## Syn node... + syn_node = Node("syn_%s" % id) + + syn_tau = Parameter(id="syn_tau", value=syn_tau) + syn_node.parameters.append(syn_tau) + + ip_spike = InputPort(id="spike_input", shape="(%i,)" % num_cells) + syn_node.input_ports.append(ip_spike) + + spike_weights = Parameter(id="spike_weights", value=numpy.identity(num_cells)) + syn_node.parameters.append(spike_weights) + + weighted_spike = Parameter( + id="weighted_spike", + function="MatMul", + args={"A": spike_weights.id, "B": ip_spike.id}, + ) + syn_node.parameters.append(weighted_spike) + + pc = ParameterCondition( + id="spike_detected", + test="%s > 0" % ip_spike.id, + value="%s" % (weighted_spike.id), + ) + + syn_i = Parameter( + id="syn_i", + default_initial_value="0", + time_derivative="-1 * syn_i", + ) + syn_i.conditions.append(pc) + syn_node.parameters.append(syn_i) + + op_v = OutputPort(id="current_output", value="syn_i") + syn_node.output_ports.append(op_v) + + ## IAF node... + iaf_node = Node(id) + + ip_current = InputPort(id="current_input", shape="(%i,)" % num_cells) + iaf_node.input_ports.append(ip_current) + + v0 = Parameter( + id="v0", + value=numpy.array([v0] * num_cells) if isinstance(v0, (int, float)) else v0, ) - syn_i.conditions.append(pc) - iaf_node.parameters.append(syn_i) + iaf_node.parameters.append(v0) + + erev = Parameter(id="erev", value=numpy.array([erev] * num_cells)) + iaf_node.parameters.append(erev) + + tau = Parameter(id="tau", value=tau) + iaf_node.parameters.append(tau) + + thresh = Parameter(id="thresh", value=numpy.array([thresh] * num_cells)) + iaf_node.parameters.append(thresh) pc1 = ParameterCondition(id="is_spiking", test="v >= thresh", value="1") pc2 = ParameterCondition(id="not_spiking", test="v < thresh", value="0") @@ -65,89 +125,99 @@ def create_iaf_node(id, num_cells=1): v = Parameter( id="v", default_initial_value="v0", - time_derivative=f"-1 * (v-erev)/tau + {syn_i.id} + {ip_current.id}", + time_derivative=f"-1 * (v-erev)/tau + {ip_current.id}", ) v.conditions.append(pc) iaf_node.parameters.append(v) - op_v = OutputPort(id="out_port_v", value="v") + op_v = OutputPort(id="v_output", value="v") iaf_node.output_ports.append(op_v) - op_spiking = OutputPort(id="out_port_spiking", value="spiking") + op_spiking = OutputPort(id="spiking_output", value="spiking") iaf_node.output_ports.append(op_spiking) - if num_cells > 1: - v0.value = numpy.array([random.random() * 20 - 70 for r in range(num_cells)]) - erev.value = numpy.array([-70.0] * len(v0.value)) - thresh.value = numpy.array([-20.0] * len(v0.value)) - # e1.parameters['weight'] = [1,.5] + if syn_also: + + internal_edge = Edge( + id="%s_internal_edge" % id, + sender=syn_node.id, + sender_port=syn_node.get_output_port("current_output").id, + receiver=iaf_node.id, + receiver_port=iaf_node.get_input_port("current_input").id, + ) - return iaf_node + return iaf_node, syn_node, internal_edge + else: + return iaf_node def main(): mod = Model(id="IAFs") net = "-net" in sys.argv + net2 = "-net2" in sys.argv + net3 = "-net3" in sys.argv + if net: mod.id = "IAF_net" + if net2: + mod.id = "IAF_net2" + if net3: + mod.id = "IAF_net3" + + some_net = net or net2 or net3 - num_cells = 8 if net else 1 + num_cells = 8 if net or net2 else (1 if net3 else 1) mod_graph = Graph(id="iaf_example") mod.graphs.append(mod_graph) - ## Counter node - input_node = Node(id="input_node") - - t_param = Parameter(id="time", default_initial_value=0, time_derivative="1") - input_node.parameters.append(t_param) - - start = Parameter(id="start", value=20) - input_node.parameters.append(start) - - dur = Parameter(id="duration", value=60) - input_node.parameters.append(dur) - - amp = Parameter(id="amplitude", value=10) - input_node.parameters.append(amp) + start = 20 + duration = 60 + amplitude = 10 if num_cells > 1: - amp.value = numpy.array([random.random() * 20 for r in range(num_cells)]) - - level = Parameter(id="level", value=0) - - level.conditions.append( - ParameterCondition( - id="on", test="time > start and time < start + duration", value=amp.id - ) + amplitude = numpy.array([random.random() * 20 for r in range(num_cells)]) + + if net2: + amplitude = 15 + start = numpy.arange(10, 10 * (num_cells + 1), 10) + duration = numpy.ones(num_cells) * 5 + # t_param.default_initial_value = numpy.zeros(num_cells) + # t_param.time_derivative = str([0]*num_cells) + + if net3: + amplitude = 10 + start = 20 + duration = 10 + + input_node = create_current_pulse_node( + "current_input_node", start, duration, amplitude ) - level.conditions.append( - ParameterCondition( - id="off", test="time > start + duration", value="amplitude*0" - ) - ) - - input_node.parameters.append(level) - op1 = OutputPort(id="out_port", value=level.id) - input_node.output_ports.append(op1) + mod_graph.nodes.append(input_node) - # op2 = OutputPort(id="t_out_port", value=t_param.id) - # input_node.output_ports.append(op2) + if net3: + input_node2 = create_current_pulse_node("current_input_node2", 60, 10, 3) + mod_graph.nodes.append(input_node2) - mod_graph.nodes.append(input_node) + v0 = ( + numpy.array([random.random() * 20 - 70 for r in range(num_cells)]) + if net + else -70 + if net2 + else -60 + ) - iaf_node1 = create_iaf_node("pre", num_cells) + iaf_node1 = create_iaf_syn_node("pre", num_cells, syn_also=False, v0=v0) mod_graph.nodes.append(iaf_node1) e1 = Edge( id="input_edge", - parameters={"weight": 1}, sender=input_node.id, - sender_port=input_node.get_output_port("out_port").id, + sender_port=input_node.get_output_port("current_output").id, receiver=iaf_node1.id, receiver_port=iaf_node1.get_input_port("current_input").id, ) @@ -155,31 +225,65 @@ def main(): mod_graph.edges.append(e1) mod_graph.nodes.append(iaf_node1) - iaf_node2 = create_iaf_node("post", num_cells) + if net3: + e2 = Edge( + id="input_edge2", + sender=input_node2.id, + sender_port=input_node2.get_output_port("current_output").id, + receiver=iaf_node1.id, + receiver_port=iaf_node1.get_input_port("current_input").id, + ) + + mod_graph.edges.append(e2) + + iaf_node2, syn_node2, internal_edge2 = create_iaf_syn_node( + "post", num_cells, syn_also=True, v0=v0 + ) mod_graph.nodes.append(iaf_node2) + mod_graph.nodes.append(syn_node2) + mod_graph.edges.append(internal_edge2) + + if net2: + iaf_node2.get_parameter("tau").value = 1 + + weight = [40] + if net: + weight = numpy.ones([num_cells, num_cells]) * 40 + if net2: + weight = numpy.identity(num_cells) + for i in range(num_cells): + weight[i, i] = i + + syn_node2.get_parameter("spike_weights").value = weight e2 = Edge( id="syn_edge", - parameters={"weight": 40}, sender=iaf_node1.id, - sender_port=iaf_node1.get_output_port("out_port_spiking").id, - receiver=iaf_node2.id, - receiver_port=iaf_node2.get_input_port("spike_input").id, + sender_port=iaf_node1.get_output_port("spiking_output").id, + receiver=syn_node2.id, + receiver_port=syn_node2.get_input_port("spike_input").id, ) mod_graph.edges.append(e2) - new_file = mod.to_json_file("%s.json" % mod.id) - new_file = mod.to_yaml_file("%s.yaml" % mod.id) + j_file = "%s.json" % mod.id + new_file = mod.to_json_file(j_file) + print("Saved to %s" % j_file) + y_file = "%s.yaml" % mod.id + new_file = mod.to_yaml_file(y_file) + print("Saved to %s" % y_file) if "-run" in sys.argv: verbose = "-v" in sys.argv from modeci_mdf.utils import load_mdf, print_summary - from modeci_mdf.execution_engine import EvaluableGraph + from modelspec.utils import FORMAT_NUMPY, FORMAT_TENSORFLOW + + format = FORMAT_TENSORFLOW if "-tf" in sys.argv else FORMAT_NUMPY + eg = EvaluableGraph(mod_graph, verbose) dt = 0.1 @@ -199,15 +303,23 @@ def main(): times.append(t_ext) print("====== Evaluating at t = %s ======" % (t_ext)) if t_ext == 0: - eg.evaluate() # replace with initialize? + eg.evaluate(array_format=format) # replace with initialize? else: - eg.evaluate(time_increment=dt) + eg.evaluate(time_increment=dt, array_format=format) - i.append(eg.enodes["input_node"].evaluable_outputs["out_port"].curr_value) - t.append(eg.enodes["input_node"].evaluable_parameters["time"].curr_value) - s1.append(eg.enodes["pre"].evaluable_outputs["out_port_v"].curr_value) + if verbose: + print( + " Out v: %s" + % eg.enodes["post"].evaluable_outputs["v_output"].curr_value + ) + + i.append( + eg.enodes[input_node.id].evaluable_outputs["current_output"].curr_value + ) + t.append(eg.enodes[input_node.id].evaluable_parameters["time"].curr_value) + s1.append(eg.enodes["pre"].evaluable_outputs["v_output"].curr_value) sp1.append(eg.enodes["pre"].evaluable_parameters["spiking"].curr_value) - s2.append(eg.enodes["post"].evaluable_outputs["out_port_v"].curr_value) + s2.append(eg.enodes["post"].evaluable_outputs["v_output"].curr_value) sp2.append(eg.enodes["post"].evaluable_parameters["spiking"].curr_value) t_ext += dt @@ -217,6 +329,8 @@ def main(): # axis[0].plot(times, t, label="time at input node") + markersize = 2 if num_cells < 20 else 0.5 + if type(i[0]) == numpy.ndarray and i[0].size > 1: for ii in range(len(i[0])): iii = [] @@ -228,7 +342,7 @@ def main(): else: axis[0].plot(times, i, label="Input node current", color="k") - if not net: + if not some_net: axis[0].legend() if type(s1[0]) == numpy.ndarray and s1[0].size > 1: @@ -240,7 +354,7 @@ def main(): else: axis[1].plot(times, s1, label="IaF pre v", color="r") - if not net: + if not some_net: axis[1].legend() if type(s2[0]) == numpy.ndarray and s2[0].size > 1: @@ -252,7 +366,7 @@ def main(): else: axis[2].plot(times, s2, label="IaF post v", color="b") - if not net: + if not some_net: axis[2].legend() if type(sp1[0]) == numpy.ndarray and sp1[0].size > 1: @@ -262,9 +376,13 @@ def main(): sps1.append(sp1[ti][spi1]) nz = [t * dt for t in numpy.nonzero(sps1)][0] - print(nz) axis[3].plot( - nz, numpy.ones(len(nz)) * spi1, marker=".", color="r", linewidth=0 + nz, + numpy.ones(len(nz)) * spi1, + marker=".", + color="r", + linewidth=0, + markersize=markersize, ) for spi in range(len(sp2[0])): @@ -273,17 +391,16 @@ def main(): sps.append(sp2[ti][spi]) nz = [t * dt for t in numpy.nonzero(sps)][0] - print(nz) axis[3].plot( nz, numpy.ones(len(nz)) * spi + num_cells, marker=".", color="b", linewidth=0, + markersize=markersize, ) else: nz1 = [t * dt for t in numpy.nonzero(sp1)][0] - print(nz1) axis[3].plot( nz1, numpy.zeros(len(nz1)), @@ -293,7 +410,6 @@ def main(): color="r", ) nz2 = [t * dt for t in numpy.nonzero(sp2)][0] - print(nz2) axis[3].plot( nz2, numpy.ones(len(nz2)), @@ -309,7 +425,15 @@ def main(): plt.xlim([0, duration]) plt.xlabel("Time") - plt.savefig("IaF%s.run.png" % (".net" if net else ""), bbox_inches="tight") + plt.savefig( + "IaF%s.run.png" + % ( + ".net" + if (net) + else (".net2" if (net2) else (".net3" if (net3) else "")) + ), + bbox_inches="tight", + ) if "-nogui" not in sys.argv: plt.show() @@ -320,9 +444,16 @@ def main(): output_format="png", view_on_render=False, level=2, - filename_root="iaf", + filename_root="iaf%s" + % ( + ".net" + if (net) + else (".net2" if (net2) else (".net3" if (net3) else "")) + ), is_horizontal=True, - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) if "-neuroml" in sys.argv: diff --git a/examples/MDF/RNN/generate_rnn.py b/examples/MDF/RNN/generate_rnn.py index f4bdc67b8..2ce00a503 100644 --- a/examples/MDF/RNN/generate_rnn.py +++ b/examples/MDF/RNN/generate_rnn.py @@ -6,6 +6,7 @@ import sys import numpy as np import time +import os from utils import create_rnn_node @@ -62,7 +63,7 @@ def main(): readout_node = Node(id="readout_node") - ipro = InputPort(id="input") + ipro = InputPort(id="input", shape="(%i,)" % N) readout_node.input_ports.append(ipro) wr = Parameter(id="wr", value=np.ones(N)) @@ -185,7 +186,9 @@ def main(): view_on_render=False, level=2, filename_root="rnn", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) return mod_graph diff --git a/examples/MDF/RNN/iaf.net.png b/examples/MDF/RNN/iaf.net.png new file mode 100644 index 000000000..0fea0853a Binary files /dev/null and b/examples/MDF/RNN/iaf.net.png differ diff --git a/examples/MDF/RNN/iaf.net2.png b/examples/MDF/RNN/iaf.net2.png new file mode 100644 index 000000000..b86488593 Binary files /dev/null and b/examples/MDF/RNN/iaf.net2.png differ diff --git a/examples/MDF/RNN/iaf.png b/examples/MDF/RNN/iaf.png index ab277fe7f..865ce7469 100644 Binary files a/examples/MDF/RNN/iaf.png and b/examples/MDF/RNN/iaf.png differ diff --git a/examples/MDF/RNN/regenerate.sh b/examples/MDF/RNN/regenerate.sh index 8ce7604c4..13796379d 100755 --- a/examples/MDF/RNN/regenerate.sh +++ b/examples/MDF/RNN/regenerate.sh @@ -5,8 +5,11 @@ python generate_rnn.py -graph python generate_rnn.py -run -nogui python generate_iaf.py -graph +python generate_iaf.py -net -graph +python generate_iaf.py -net2 -graph python generate_iaf.py -run -nogui python generate_iaf.py -run -net -nogui +python generate_iaf.py -run -net2 -nogui #Fix dimensions! #python generate_iaf.py -neuroml pynml LEMS_Simiaf_example.xml -lems-graph diff --git a/examples/MDF/RNN/rnn.png b/examples/MDF/RNN/rnn.png index 9f31f4271..661836127 100644 Binary files a/examples/MDF/RNN/rnn.png and b/examples/MDF/RNN/rnn.png differ diff --git a/examples/MDF/RNN/utils.py b/examples/MDF/RNN/utils.py index 1849a3626..6688add94 100644 --- a/examples/MDF/RNN/utils.py +++ b/examples/MDF/RNN/utils.py @@ -8,10 +8,10 @@ def create_rnn_node(id, N, g, seed=1234): ## RNN node... rnn_node = Node(id=id) - ipr1 = InputPort(id="ext_input") + ipr1 = InputPort(id="ext_input", shape="(%i,)" % N) rnn_node.input_ports.append(ipr1) - ipr2 = InputPort(id="fb_input") + ipr2 = InputPort(id="fb_input", shape="(%i,)" % N) rnn_node.input_ports.append(ipr2) default_initial_value = np.zeros(N) diff --git a/examples/MDF/Simple.bson b/examples/MDF/Simple.bson index 51c202475..c24db249b 100644 Binary files a/examples/MDF/Simple.bson and b/examples/MDF/Simple.bson differ diff --git a/examples/MDF/Simple.json b/examples/MDF/Simple.json index e1f3adb3f..2ab426980 100644 --- a/examples/MDF/Simple.json +++ b/examples/MDF/Simple.json @@ -1,7 +1,7 @@ { "Simple": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "simple_example": { "nodes": { diff --git a/examples/MDF/Simple.yaml b/examples/MDF/Simple.yaml index 7dcd160ba..b212c7532 100644 --- a/examples/MDF/Simple.yaml +++ b/examples/MDF/Simple.yaml @@ -1,6 +1,6 @@ Simple: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: simple_example: nodes: diff --git a/examples/MDF/States.json b/examples/MDF/States.json index dff6cac76..4a9d18397 100644 --- a/examples/MDF/States.json +++ b/examples/MDF/States.json @@ -1,7 +1,7 @@ { "States": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "state_example": { "nodes": { diff --git a/examples/MDF/States.yaml b/examples/MDF/States.yaml index ad25fa31c..18c95af3e 100644 --- a/examples/MDF/States.yaml +++ b/examples/MDF/States.yaml @@ -1,6 +1,6 @@ States: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: state_example: nodes: diff --git a/examples/MDF/abc_conditions.json b/examples/MDF/abc_conditions.json index 608529ab2..1c69081e9 100644 --- a/examples/MDF/abc_conditions.json +++ b/examples/MDF/abc_conditions.json @@ -1,7 +1,7 @@ { "abc_conditions": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "abc_conditions_example": { "nodes": { diff --git a/examples/MDF/abc_conditions.py b/examples/MDF/abc_conditions.py index 91884ad43..4d52ba21b 100644 --- a/examples/MDF/abc_conditions.py +++ b/examples/MDF/abc_conditions.py @@ -99,7 +99,9 @@ def create_simple_node(graph, id_, sender=None): view_on_render=False, level=3, filename_root="abc_conditions", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/abc_conditions.yaml b/examples/MDF/abc_conditions.yaml index f79ed72cd..3e6a5a931 100644 --- a/examples/MDF/abc_conditions.yaml +++ b/examples/MDF/abc_conditions.yaml @@ -1,6 +1,6 @@ abc_conditions: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: abc_conditions_example: nodes: diff --git a/examples/MDF/abcd.py b/examples/MDF/abcd.py index aa0aceb2b..4ba690c87 100644 --- a/examples/MDF/abcd.py +++ b/examples/MDF/abcd.py @@ -7,6 +7,7 @@ from modeci_mdf.utils import simple_connect, print_summary import abcd_python as abcd +import os def main(): @@ -131,7 +132,9 @@ def main(): view_on_render=False, level=1, filename_root="abcd", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions is_horizontal=True, ) mod.to_graph_image( @@ -140,7 +143,9 @@ def main(): view_on_render=False, level=3, filename_root="abcd_3", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/arrays.py b/examples/MDF/arrays.py index 94c51eb9c..33113e8d0 100644 --- a/examples/MDF/arrays.py +++ b/examples/MDF/arrays.py @@ -5,6 +5,7 @@ from modeci_mdf.mdf import * import sys import numpy as np +import os def main(): @@ -26,7 +27,7 @@ def main(): Parameter(id="intercept", value=np.array([[0, 1.0], [2, 2]])) ) - ip1 = InputPort(id="input_port1") + ip1 = InputPort(id="input_port1", shape="(2,2)") middle_node.input_ports.append(ip1) mod_graph.nodes.append(middle_node) @@ -71,7 +72,9 @@ def main(): view_on_render=False, level=3, filename_root="arrays", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/conditions/Composite_mdf_condition.json b/examples/MDF/conditions/Composite_mdf_condition.json index 487545478..6bd4efed2 100644 --- a/examples/MDF/conditions/Composite_mdf_condition.json +++ b/examples/MDF/conditions/Composite_mdf_condition.json @@ -1,7 +1,7 @@ { "Composite_mdf_condition": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "Composite_mdf_condition_example": { "nodes": { diff --git a/examples/MDF/conditions/Composite_mdf_condition.yaml b/examples/MDF/conditions/Composite_mdf_condition.yaml index 1196a638d..9a4878998 100644 --- a/examples/MDF/conditions/Composite_mdf_condition.yaml +++ b/examples/MDF/conditions/Composite_mdf_condition.yaml @@ -1,6 +1,6 @@ Composite_mdf_condition: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: Composite_mdf_condition_example: nodes: diff --git a/examples/MDF/conditions/composite_condition_example.py b/examples/MDF/conditions/composite_condition_example.py index 401af3294..a2884335b 100644 --- a/examples/MDF/conditions/composite_condition_example.py +++ b/examples/MDF/conditions/composite_condition_example.py @@ -75,7 +75,9 @@ def create_simple_node(graph, id_, sender=None): view_on_render=False, level=3, filename_root="composite_example", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/conditions/everyNCalls.py b/examples/MDF/conditions/everyNCalls.py index 62253d44a..f096516a3 100644 --- a/examples/MDF/conditions/everyNCalls.py +++ b/examples/MDF/conditions/everyNCalls.py @@ -81,7 +81,9 @@ def create_simple_node(graph, id_, sender=None): view_on_render=False, level=3, filename_root="everyncalls", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/conditions/everyncalls_condition.json b/examples/MDF/conditions/everyncalls_condition.json index b19807501..f1a3ca25e 100644 --- a/examples/MDF/conditions/everyncalls_condition.json +++ b/examples/MDF/conditions/everyncalls_condition.json @@ -1,7 +1,7 @@ { "everyncalls_condition": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "everyncalls_example": { "nodes": { diff --git a/examples/MDF/conditions/everyncalls_condition.yaml b/examples/MDF/conditions/everyncalls_condition.yaml index 3227361be..79d7cb039 100644 --- a/examples/MDF/conditions/everyncalls_condition.yaml +++ b/examples/MDF/conditions/everyncalls_condition.yaml @@ -1,6 +1,6 @@ everyncalls_condition: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: everyncalls_example: nodes: diff --git a/examples/MDF/conditions/images/composite_example.png b/examples/MDF/conditions/images/composite_example.png index ed3e4686d..beab1cf10 100644 Binary files a/examples/MDF/conditions/images/composite_example.png and b/examples/MDF/conditions/images/composite_example.png differ diff --git a/examples/MDF/conditions/images/everyncalls.png b/examples/MDF/conditions/images/everyncalls.png index 86f7c2e0d..f687575fa 100644 Binary files a/examples/MDF/conditions/images/everyncalls.png and b/examples/MDF/conditions/images/everyncalls.png differ diff --git a/examples/MDF/conditions/images/threshold.png b/examples/MDF/conditions/images/threshold.png index f15fe04c9..537229b3e 100644 Binary files a/examples/MDF/conditions/images/threshold.png and b/examples/MDF/conditions/images/threshold.png differ diff --git a/examples/MDF/conditions/images/timeinterval.png b/examples/MDF/conditions/images/timeinterval.png index 609f4cf0b..c151c3786 100644 Binary files a/examples/MDF/conditions/images/timeinterval.png and b/examples/MDF/conditions/images/timeinterval.png differ diff --git a/examples/MDF/conditions/threshold.py b/examples/MDF/conditions/threshold.py index f147c6b80..ca45fd544 100644 --- a/examples/MDF/conditions/threshold.py +++ b/examples/MDF/conditions/threshold.py @@ -81,7 +81,9 @@ def create_simple_node(graph, id_, sender=None): view_on_render=False, level=3, filename_root="threshold", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/conditions/threshold_condition.json b/examples/MDF/conditions/threshold_condition.json index b4a3b8fa3..74f6b60a8 100644 --- a/examples/MDF/conditions/threshold_condition.json +++ b/examples/MDF/conditions/threshold_condition.json @@ -1,7 +1,7 @@ { "threshold_condition": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "threshold_example": { "nodes": { diff --git a/examples/MDF/conditions/threshold_condition.yaml b/examples/MDF/conditions/threshold_condition.yaml index e7e49bca9..2d498c8ee 100644 --- a/examples/MDF/conditions/threshold_condition.yaml +++ b/examples/MDF/conditions/threshold_condition.yaml @@ -1,6 +1,6 @@ threshold_condition: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: threshold_example: nodes: diff --git a/examples/MDF/conditions/timeInterval.py b/examples/MDF/conditions/timeInterval.py index e8f9a670c..6219becbb 100644 --- a/examples/MDF/conditions/timeInterval.py +++ b/examples/MDF/conditions/timeInterval.py @@ -82,7 +82,9 @@ def create_simple_node(graph, id_, sender=None): view_on_render=False, level=3, filename_root="timeinterval", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) return mod_graph diff --git a/examples/MDF/conditions/timeinterval_condition.json b/examples/MDF/conditions/timeinterval_condition.json index a0c3127bc..1e788cb30 100644 --- a/examples/MDF/conditions/timeinterval_condition.json +++ b/examples/MDF/conditions/timeinterval_condition.json @@ -1,7 +1,7 @@ { "timeinterval_condition": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "timeinterval_example": { "nodes": { diff --git a/examples/MDF/conditions/timeinterval_condition.yaml b/examples/MDF/conditions/timeinterval_condition.yaml index 5a86de430..7df4abb2f 100644 --- a/examples/MDF/conditions/timeinterval_condition.yaml +++ b/examples/MDF/conditions/timeinterval_condition.yaml @@ -1,6 +1,6 @@ timeinterval_condition: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: timeinterval_example: nodes: diff --git a/examples/MDF/images/abc_conditions.png b/examples/MDF/images/abc_conditions.png index 8e44ebb40..88508848f 100644 Binary files a/examples/MDF/images/abc_conditions.png and b/examples/MDF/images/abc_conditions.png differ diff --git a/examples/MDF/images/abcd.png b/examples/MDF/images/abcd.png index 3e1b02fa0..3d02389f9 100644 Binary files a/examples/MDF/images/abcd.png and b/examples/MDF/images/abcd.png differ diff --git a/examples/MDF/images/abcd_3.png b/examples/MDF/images/abcd_3.png index 2a15ca11e..2a77534f5 100644 Binary files a/examples/MDF/images/abcd_3.png and b/examples/MDF/images/abcd_3.png differ diff --git a/examples/MDF/images/arrays.png b/examples/MDF/images/arrays.png index 2d335c77c..3c3b1dd69 100644 Binary files a/examples/MDF/images/arrays.png and b/examples/MDF/images/arrays.png differ diff --git a/examples/MDF/images/params_funcs.png b/examples/MDF/images/params_funcs.png index 9d9d0365d..d9921eb15 100644 Binary files a/examples/MDF/images/params_funcs.png and b/examples/MDF/images/params_funcs.png differ diff --git a/examples/MDF/images/simple.png b/examples/MDF/images/simple.png index ccda3c0df..7d2983f5c 100644 Binary files a/examples/MDF/images/simple.png and b/examples/MDF/images/simple.png differ diff --git a/examples/MDF/images/simple_3.png b/examples/MDF/images/simple_3.png index 8275edceb..fa64c3c01 100644 Binary files a/examples/MDF/images/simple_3.png and b/examples/MDF/images/simple_3.png differ diff --git a/examples/MDF/images/states.png b/examples/MDF/images/states.png index a9d1fef26..ce5db8c5e 100644 Binary files a/examples/MDF/images/states.png and b/examples/MDF/images/states.png differ diff --git a/examples/MDF/params_funcs.py b/examples/MDF/params_funcs.py index 4b054e313..f1c3306e3 100644 --- a/examples/MDF/params_funcs.py +++ b/examples/MDF/params_funcs.py @@ -7,6 +7,7 @@ from modeci_mdf.utils import simple_connect, print_summary import abcd_python as abcd +import os def main(): @@ -88,7 +89,9 @@ def main(): view_on_render=False, level=3, filename_root="%s" % mod_graph.id, - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/scaling.py b/examples/MDF/scaling.py index eabdd5a07..7c84fbd12 100644 --- a/examples/MDF/scaling.py +++ b/examples/MDF/scaling.py @@ -40,7 +40,7 @@ def generate_test_model( hidden_node = Node(id="hidden_node_%i" % i) - hidden_node.input_ports.append(InputPort(id="in_port")) + hidden_node.input_ports.append(InputPort(id="in_port", shape=input_shape)) hidden_node.parameters.append(Parameter(id="slope0", value=0.5)) hidden_node.parameters.append( Parameter( @@ -80,7 +80,7 @@ def generate_test_model( id="output_node", ) - output_node.input_ports.append(InputPort(id="in_port")) + output_node.input_ports.append(InputPort(id="in_port", shape=output_shape)) output_node.output_ports.append(OutputPort(id="out_port", value="in_port")) mod_graph.nodes.append(output_node) diff --git a/examples/MDF/simple.py b/examples/MDF/simple.py index b8c79a6e3..438163636 100644 --- a/examples/MDF/simple.py +++ b/examples/MDF/simple.py @@ -90,7 +90,9 @@ def main(): view_on_render=False, level=1, filename_root="simple", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) mod.to_graph_image( engine="dot", @@ -98,7 +100,9 @@ def main(): view_on_render=False, level=3, filename_root="simple_3", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/MDF/states.py b/examples/MDF/states.py index 0afe544e8..32579d360 100644 --- a/examples/MDF/states.py +++ b/examples/MDF/states.py @@ -90,7 +90,9 @@ def main(): view_on_render=False, level=3, filename_root="states", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) return mod_graph diff --git a/examples/NeuroML/ABCD.1.mdf.png b/examples/NeuroML/ABCD.1.mdf.png index 0e2abb4ce..2972c1bdd 100644 Binary files a/examples/NeuroML/ABCD.1.mdf.png and b/examples/NeuroML/ABCD.1.mdf.png differ diff --git a/examples/NeuroML/ABCD.json b/examples/NeuroML/ABCD.json index 55350e9b3..ba35670b7 100644 --- a/examples/NeuroML/ABCD.json +++ b/examples/NeuroML/ABCD.json @@ -1,6 +1,6 @@ { "ABCD": { - "version": "NeuroMLlite v0.5.3", + "version": "NeuroMLlite v0.5.5", "notes": "Example of a simplified network", "parameters": { "A_initial": 0.1, diff --git a/examples/NeuroML/ABCD.mdf.json b/examples/NeuroML/ABCD.mdf.json index 386811a1e..fc67c977b 100644 --- a/examples/NeuroML/ABCD.mdf.json +++ b/examples/NeuroML/ABCD.mdf.json @@ -1,11 +1,11 @@ { "ABCD": { - "format": "ModECI MDF v0.3", + "format": "ModECI MDF v0.4", "graphs": { "ABCD": { "notes": "Example of a simplified network", "nodes": { - "A_input_0": { + "A_input": { "metadata": { "color": "0.2 0.2 0.2", "radius": 3, @@ -13,7 +13,24 @@ }, "parameters": { "variable": { - "value": 2.0 + "value": [ + 2.0 + ] + }, + "spike": { + "default_initial_value": [ + 0 + ], + "conditions": { + "condition_0_on": { + "test": "OUTPUT < 0", + "value": 1 + }, + "condition_0_off": { + "test": "spike > 0", + "value": 0 + } + } }, "V": { "value": 0 @@ -26,6 +43,9 @@ "INPUT": {} }, "output_ports": { + "spike": { + "value": "spike" + }, "V": { "value": "V" }, @@ -35,7 +55,7 @@ }, "notes": "Cell: [Cell(notes=None, id='a_input', parameters={'variable': 'A_initial'}, neuroml2_source_file=None, lems_source_file='PNL.xml', neuroml2_cell=None, pynn_cell=None, arbor_cell=None, bindsnet_node=None)] is defined in PNL.xml and in Lems is: Component, id: a_input, type: inputNode,\n parameters: {'variable': '2'}\n parent: None\n" }, - "A_0": { + "A": { "metadata": { "color": "0 0.9 0", "radius": 5, @@ -43,10 +63,29 @@ }, "parameters": { "slope": { - "value": 2.0 + "value": [ + 2.0 + ] }, "intercept": { - "value": 2.0 + "value": [ + 2.0 + ] + }, + "spike": { + "default_initial_value": [ + 0 + ], + "conditions": { + "condition_0_on": { + "test": "OUTPUT < 0", + "value": 1 + }, + "condition_0_off": { + "test": "spike > 0", + "value": 0 + } + } }, "V": { "value": 0 @@ -59,6 +98,9 @@ "INPUT": {} }, "output_ports": { + "spike": { + "value": "spike" + }, "V": { "value": "V" }, @@ -68,7 +110,7 @@ }, "notes": "Cell: [Cell(notes=None, id='a', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', neuroml2_cell=None, pynn_cell=None, arbor_cell=None, bindsnet_node=None)] is defined in PNL.xml and in Lems is: Component, id: a, type: pnlLinearFunctionTM,\n parameters: {'slope': '2', 'intercept': '2'}\n parent: None\n" }, - "B_0": { + "B": { "metadata": { "color": ".8 .8 .8", "radius": 5, @@ -76,28 +118,54 @@ }, "parameters": { "gain": { - "value": 1.0 + "value": [ + 1.0 + ] }, "bias": { - "value": 0.0 + "value": [ + 0.0 + ] }, "x_0": { - "value": 0.0 + "value": [ + 0.0 + ] }, "offset": { - "value": 0.0 + "value": [ + 0.0 + ] + }, + "spike": { + "default_initial_value": [ + 0 + ], + "conditions": { + "condition_0_on": { + "test": "OUTPUT < 0", + "value": 1 + }, + "condition_0_off": { + "test": "spike > 0", + "value": 0 + } + } }, "V": { "value": 0 }, "OUTPUT": { - "value": "1/(1+math.exp(-1*gain*(INPUT + bias - x_0)+offset))" + "value": "1/(1+numpy.exp(-1*gain*(INPUT + bias - x_0)+offset))" } }, "input_ports": { "INPUT": {} }, "output_ports": { + "spike": { + "value": "spike" + }, "V": { "value": "V" }, @@ -107,7 +175,7 @@ }, "notes": "Cell: [Cell(notes=None, id='b', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', neuroml2_cell=None, pynn_cell=None, arbor_cell=None, bindsnet_node=None)] is defined in PNL.xml and in Lems is: Component, id: b, type: pnlLogisticFunctionTM,\n parameters: {'gain': '1.0', 'bias': '0.0', 'x_0': '0.0', 'offset': '0.0'}\n parent: None\n" }, - "C_0": { + "C": { "metadata": { "color": "0.7 0.7 0.7", "radius": 5, @@ -115,28 +183,54 @@ }, "parameters": { "rate": { - "value": 1.0 + "value": [ + 1.0 + ] }, "bias": { - "value": 0.0 + "value": [ + 0.0 + ] }, "scale": { - "value": 1.0 + "value": [ + 1.0 + ] }, "offset": { - "value": 0.0 + "value": [ + 0.0 + ] + }, + "spike": { + "default_initial_value": [ + 0 + ], + "conditions": { + "condition_0_on": { + "test": "OUTPUT < 0", + "value": 1 + }, + "condition_0_off": { + "test": "spike > 0", + "value": 0 + } + } }, "V": { "value": 0 }, "OUTPUT": { - "value": "scale * math.exp((rate * INPUT) + bias) + offset" + "value": "scale * numpy.exp((rate * INPUT) + bias) + offset" } }, "input_ports": { "INPUT": {} }, "output_ports": { + "spike": { + "value": "spike" + }, "V": { "value": "V" }, @@ -146,7 +240,7 @@ }, "notes": "Cell: [Cell(notes=None, id='c', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', neuroml2_cell=None, pynn_cell=None, arbor_cell=None, bindsnet_node=None)] is defined in PNL.xml and in Lems is: Component, id: c, type: pnlExponentialFunctionTM,\n parameters: {'rate': '1.0', 'bias': '0.0', 'scale': '1.0', 'offset': '0.0'}\n parent: None\n" }, - "D_0": { + "D": { "metadata": { "color": "0.7 0 0", "radius": 5, @@ -154,13 +248,35 @@ }, "parameters": { "rate": { - "value": 0.05 + "value": [ + 0.05 + ] }, "time_step_size": { - "value": 0.1 + "value": [ + 0.1 + ] + }, + "spike": { + "default_initial_value": [ + 0 + ], + "conditions": { + "condition_0_on": { + "test": "OUTPUT < 0", + "value": 1 + }, + "condition_0_off": { + "test": "spike > 0", + "value": 0 + } + } }, "OUTPUT": { - "time_derivative": "(rate * INPUT) / time_step_size" + "time_derivative": "(rate * INPUT) / time_step_size", + "default_initial_value": [ + 0 + ] }, "V": { "value": 0 @@ -170,6 +286,9 @@ "INPUT": {} }, "output_ports": { + "spike": { + "value": "spike" + }, "OUTPUT": { "value": "OUTPUT" }, @@ -178,48 +297,223 @@ } }, "notes": "Cell: [Cell(notes=None, id='d', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', neuroml2_cell=None, pynn_cell=None, arbor_cell=None, bindsnet_node=None)] is defined in PNL.xml and in Lems is: Component, id: d, type: pnlSimpleIntegratorMechanism,\n parameters: {'rate': '0.05', 'time_step_size': '0.1s'}\n parent: None\n" + }, + "proj_input_rsDL": { + "parameters": { + "weight": { + "value": [ + 1.0 + ] + }, + "SEC": { + "value": [ + 1.0 + ] + }, + "rpeer": { + "value": "peer_OUTPUT" + }, + "I": { + "value": "weight * rpeer" + } + }, + "input_ports": { + "peer_OUTPUT": {} + }, + "output_ports": { + "I": { + "value": "I" + } + }, + "notes": "Cell: [Synapse(notes=None, id='rsDL', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None, pynn_receptor_type=None)] is defined in PNL.xml and in Lems is: Component, id: rsDL, type: synapseDL,\n parameters: {}\n parent: None\n" + }, + "proj0_rsDL": { + "parameters": { + "weight": { + "value": [ + 1.0 + ] + }, + "SEC": { + "value": [ + 1.0 + ] + }, + "rpeer": { + "value": "peer_OUTPUT" + }, + "I": { + "value": "weight * rpeer" + } + }, + "input_ports": { + "peer_OUTPUT": {} + }, + "output_ports": { + "I": { + "value": "I" + } + }, + "notes": "Cell: [Synapse(notes=None, id='rsDL', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None, pynn_receptor_type=None)] is defined in PNL.xml and in Lems is: Component, id: rsDL, type: synapseDL,\n parameters: {}\n parent: None\n" + }, + "proj1_rsDL": { + "parameters": { + "weight": { + "value": [ + 1.0 + ] + }, + "SEC": { + "value": [ + 1.0 + ] + }, + "rpeer": { + "value": "peer_OUTPUT" + }, + "I": { + "value": "weight * rpeer" + } + }, + "input_ports": { + "peer_OUTPUT": {} + }, + "output_ports": { + "I": { + "value": "I" + } + }, + "notes": "Cell: [Synapse(notes=None, id='rsDL', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None, pynn_receptor_type=None)] is defined in PNL.xml and in Lems is: Component, id: rsDL, type: synapseDL,\n parameters: {}\n parent: None\n" + }, + "proj2_rsDL": { + "parameters": { + "weight": { + "value": [ + 1.0 + ] + }, + "SEC": { + "value": [ + 1.0 + ] + }, + "rpeer": { + "value": "peer_OUTPUT" + }, + "I": { + "value": "weight * rpeer" + } + }, + "input_ports": { + "peer_OUTPUT": {} + }, + "output_ports": { + "I": { + "value": "I" + } + }, + "notes": "Cell: [Synapse(notes=None, id='rsDL', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None, pynn_receptor_type=None)] is defined in PNL.xml and in Lems is: Component, id: rsDL, type: synapseDL,\n parameters: {}\n parent: None\n" + }, + "proj3_rsDL": { + "parameters": { + "weight": { + "value": [ + 1.0 + ] + }, + "SEC": { + "value": [ + 1.0 + ] + }, + "rpeer": { + "value": "peer_OUTPUT" + }, + "I": { + "value": "weight * rpeer" + } + }, + "input_ports": { + "peer_OUTPUT": {} + }, + "output_ports": { + "I": { + "value": "I" + } + }, + "notes": "Cell: [Synapse(notes=None, id='rsDL', parameters=None, neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None, pynn_receptor_type=None)] is defined in PNL.xml and in Lems is: Component, id: rsDL, type: synapseDL,\n parameters: {}\n parent: None\n" } }, "edges": { - "Edge A_0 to B_0": { - "name": "Edge A_0 to B_0", + "A_TO_proj_input_rsDL": { + "name": "A_TO_proj_input_rsDL", "sender_port": "OUTPUT", + "receiver_port": "peer_OUTPUT", + "sender": "A", + "receiver": "proj_input_rsDL" + }, + "proj_input_rsDL_TO_B": { + "name": "proj_input_rsDL_TO_B", + "sender_port": "I", "receiver_port": "INPUT", - "sender": "A_0", - "receiver": "B_0", - "weight": 1 + "sender": "proj_input_rsDL", + "receiver": "B" }, - "Edge A_input_0 to A_0": { - "name": "Edge A_input_0 to A_0", + "A_input_TO_proj0_rsDL": { + "name": "A_input_TO_proj0_rsDL", "sender_port": "OUTPUT", + "receiver_port": "peer_OUTPUT", + "sender": "A_input", + "receiver": "proj0_rsDL" + }, + "proj0_rsDL_TO_A": { + "name": "proj0_rsDL_TO_A", + "sender_port": "I", "receiver_port": "INPUT", - "sender": "A_input_0", - "receiver": "A_0", - "weight": 1 + "sender": "proj0_rsDL", + "receiver": "A" }, - "Edge A_0 to C_0": { - "name": "Edge A_0 to C_0", + "A_TO_proj1_rsDL": { + "name": "A_TO_proj1_rsDL", "sender_port": "OUTPUT", + "receiver_port": "peer_OUTPUT", + "sender": "A", + "receiver": "proj1_rsDL" + }, + "proj1_rsDL_TO_C": { + "name": "proj1_rsDL_TO_C", + "sender_port": "I", "receiver_port": "INPUT", - "sender": "A_0", - "receiver": "C_0", - "weight": 1 + "sender": "proj1_rsDL", + "receiver": "C" }, - "Edge B_0 to D_0": { - "name": "Edge B_0 to D_0", + "B_TO_proj2_rsDL": { + "name": "B_TO_proj2_rsDL", "sender_port": "OUTPUT", + "receiver_port": "peer_OUTPUT", + "sender": "B", + "receiver": "proj2_rsDL" + }, + "proj2_rsDL_TO_D": { + "name": "proj2_rsDL_TO_D", + "sender_port": "I", "receiver_port": "INPUT", - "sender": "B_0", - "receiver": "D_0", - "weight": 1 + "sender": "proj2_rsDL", + "receiver": "D" }, - "Edge C_0 to D_0": { - "name": "Edge C_0 to D_0", + "C_TO_proj3_rsDL": { + "name": "C_TO_proj3_rsDL", "sender_port": "OUTPUT", + "receiver_port": "peer_OUTPUT", + "sender": "C", + "receiver": "proj3_rsDL" + }, + "proj3_rsDL_TO_D": { + "name": "proj3_rsDL_TO_D", + "sender_port": "I", "receiver_port": "INPUT", - "sender": "C_0", - "receiver": "D_0", - "weight": 1 + "sender": "proj3_rsDL", + "receiver": "D" } } } diff --git a/examples/NeuroML/ABCD.mdf.png b/examples/NeuroML/ABCD.mdf.png index e804b226f..2e5ce54c4 100644 Binary files a/examples/NeuroML/ABCD.mdf.png and b/examples/NeuroML/ABCD.mdf.png differ diff --git a/examples/NeuroML/ABCD.mdf.yaml b/examples/NeuroML/ABCD.mdf.yaml index f4f6ca9bf..c3c214ada 100644 --- a/examples/NeuroML/ABCD.mdf.yaml +++ b/examples/NeuroML/ABCD.mdf.yaml @@ -1,17 +1,28 @@ ABCD: - format: ModECI MDF v0.3 + format: ModECI MDF v0.4 graphs: ABCD: notes: Example of a simplified network nodes: - A_input_0: + A_input: metadata: color: 0.2 0.2 0.2 radius: 3 region: region1 parameters: variable: - value: 2.0 + value: + - 2.0 + spike: + default_initial_value: + - 0 + conditions: + condition_0_on: + test: OUTPUT < 0 + value: 1 + condition_0_off: + test: spike > 0 + value: 0 V: value: 0 OUTPUT: @@ -19,6 +30,8 @@ ABCD: input_ports: INPUT: {} output_ports: + spike: + value: spike V: value: V OUTPUT: @@ -29,16 +42,28 @@ ABCD: \ is defined in PNL.xml and in Lems is: Component, id: a_input,\ \ type: inputNode,\n parameters: {'variable': '2'}\n parent:\ \ None\n" - A_0: + A: metadata: color: 0 0.9 0 radius: 5 region: region1 parameters: slope: - value: 2.0 + value: + - 2.0 intercept: - value: 2.0 + value: + - 2.0 + spike: + default_initial_value: + - 0 + conditions: + condition_0_on: + test: OUTPUT < 0 + value: 1 + condition_0_off: + test: spike > 0 + value: 0 V: value: 0 OUTPUT: @@ -46,6 +71,8 @@ ABCD: input_ports: INPUT: {} output_ports: + spike: + value: spike V: value: V OUTPUT: @@ -56,27 +83,43 @@ ABCD: \ and in Lems is: Component, id: a, type: pnlLinearFunctionTM,\n\ \ parameters: {'slope': '2', 'intercept': '2'}\n parent:\ \ None\n" - B_0: + B: metadata: color: .8 .8 .8 radius: 5 region: region1 parameters: gain: - value: 1.0 + value: + - 1.0 bias: - value: 0.0 + value: + - 0.0 x_0: - value: 0.0 + value: + - 0.0 offset: - value: 0.0 + value: + - 0.0 + spike: + default_initial_value: + - 0 + conditions: + condition_0_on: + test: OUTPUT < 0 + value: 1 + condition_0_off: + test: spike > 0 + value: 0 V: value: 0 OUTPUT: - value: 1/(1+math.exp(-1*gain*(INPUT + bias - x_0)+offset)) + value: 1/(1+numpy.exp(-1*gain*(INPUT + bias - x_0)+offset)) input_ports: INPUT: {} output_ports: + spike: + value: spike V: value: V OUTPUT: @@ -87,27 +130,43 @@ ABCD: \ and in Lems is: Component, id: b, type: pnlLogisticFunctionTM,\n\ \ parameters: {'gain': '1.0', 'bias': '0.0', 'x_0': '0.0',\ \ 'offset': '0.0'}\n parent: None\n" - C_0: + C: metadata: color: 0.7 0.7 0.7 radius: 5 region: region1 parameters: rate: - value: 1.0 + value: + - 1.0 bias: - value: 0.0 + value: + - 0.0 scale: - value: 1.0 + value: + - 1.0 offset: - value: 0.0 + value: + - 0.0 + spike: + default_initial_value: + - 0 + conditions: + condition_0_on: + test: OUTPUT < 0 + value: 1 + condition_0_off: + test: spike > 0 + value: 0 V: value: 0 OUTPUT: - value: scale * math.exp((rate * INPUT) + bias) + offset + value: scale * numpy.exp((rate * INPUT) + bias) + offset input_ports: INPUT: {} output_ports: + spike: + value: spike V: value: V OUTPUT: @@ -118,23 +177,39 @@ ABCD: \ and in Lems is: Component, id: c, type: pnlExponentialFunctionTM,\n\ \ parameters: {'rate': '1.0', 'bias': '0.0', 'scale': '1.0',\ \ 'offset': '0.0'}\n parent: None\n" - D_0: + D: metadata: color: 0.7 0 0 radius: 5 region: region1 parameters: rate: - value: 0.05 + value: + - 0.05 time_step_size: - value: 0.1 + value: + - 0.1 + spike: + default_initial_value: + - 0 + conditions: + condition_0_on: + test: OUTPUT < 0 + value: 1 + condition_0_off: + test: spike > 0 + value: 0 OUTPUT: time_derivative: (rate * INPUT) / time_step_size + default_initial_value: + - 0 V: value: 0 input_ports: INPUT: {} output_ports: + spike: + value: spike OUTPUT: value: OUTPUT V: @@ -145,39 +220,174 @@ ABCD: \ and in Lems is: Component, id: d, type: pnlSimpleIntegratorMechanism,\n\ \ parameters: {'rate': '0.05', 'time_step_size': '0.1s'}\n\ \ parent: None\n" + proj_input_rsDL: + parameters: + weight: + value: + - 1.0 + SEC: + value: + - 1.0 + rpeer: + value: peer_OUTPUT + I: + value: weight * rpeer + input_ports: + peer_OUTPUT: {} + output_ports: + I: + value: I + notes: "Cell: [Synapse(notes=None, id='rsDL', parameters=None,\ + \ neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None,\ + \ pynn_receptor_type=None)] is defined in PNL.xml and in Lems\ + \ is: Component, id: rsDL, type: synapseDL,\n parameters:\ + \ {}\n parent: None\n" + proj0_rsDL: + parameters: + weight: + value: + - 1.0 + SEC: + value: + - 1.0 + rpeer: + value: peer_OUTPUT + I: + value: weight * rpeer + input_ports: + peer_OUTPUT: {} + output_ports: + I: + value: I + notes: "Cell: [Synapse(notes=None, id='rsDL', parameters=None,\ + \ neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None,\ + \ pynn_receptor_type=None)] is defined in PNL.xml and in Lems\ + \ is: Component, id: rsDL, type: synapseDL,\n parameters:\ + \ {}\n parent: None\n" + proj1_rsDL: + parameters: + weight: + value: + - 1.0 + SEC: + value: + - 1.0 + rpeer: + value: peer_OUTPUT + I: + value: weight * rpeer + input_ports: + peer_OUTPUT: {} + output_ports: + I: + value: I + notes: "Cell: [Synapse(notes=None, id='rsDL', parameters=None,\ + \ neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None,\ + \ pynn_receptor_type=None)] is defined in PNL.xml and in Lems\ + \ is: Component, id: rsDL, type: synapseDL,\n parameters:\ + \ {}\n parent: None\n" + proj2_rsDL: + parameters: + weight: + value: + - 1.0 + SEC: + value: + - 1.0 + rpeer: + value: peer_OUTPUT + I: + value: weight * rpeer + input_ports: + peer_OUTPUT: {} + output_ports: + I: + value: I + notes: "Cell: [Synapse(notes=None, id='rsDL', parameters=None,\ + \ neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None,\ + \ pynn_receptor_type=None)] is defined in PNL.xml and in Lems\ + \ is: Component, id: rsDL, type: synapseDL,\n parameters:\ + \ {}\n parent: None\n" + proj3_rsDL: + parameters: + weight: + value: + - 1.0 + SEC: + value: + - 1.0 + rpeer: + value: peer_OUTPUT + I: + value: weight * rpeer + input_ports: + peer_OUTPUT: {} + output_ports: + I: + value: I + notes: "Cell: [Synapse(notes=None, id='rsDL', parameters=None,\ + \ neuroml2_source_file=None, lems_source_file='PNL.xml', pynn_synapse_type=None,\ + \ pynn_receptor_type=None)] is defined in PNL.xml and in Lems\ + \ is: Component, id: rsDL, type: synapseDL,\n parameters:\ + \ {}\n parent: None\n" edges: - Edge A_0 to B_0: - name: Edge A_0 to B_0 + A_TO_proj_input_rsDL: + name: A_TO_proj_input_rsDL sender_port: OUTPUT + receiver_port: peer_OUTPUT + sender: A + receiver: proj_input_rsDL + proj_input_rsDL_TO_B: + name: proj_input_rsDL_TO_B + sender_port: I receiver_port: INPUT - sender: A_0 - receiver: B_0 - weight: 1 - Edge A_input_0 to A_0: - name: Edge A_input_0 to A_0 + sender: proj_input_rsDL + receiver: B + A_input_TO_proj0_rsDL: + name: A_input_TO_proj0_rsDL sender_port: OUTPUT + receiver_port: peer_OUTPUT + sender: A_input + receiver: proj0_rsDL + proj0_rsDL_TO_A: + name: proj0_rsDL_TO_A + sender_port: I receiver_port: INPUT - sender: A_input_0 - receiver: A_0 - weight: 1 - Edge A_0 to C_0: - name: Edge A_0 to C_0 + sender: proj0_rsDL + receiver: A + A_TO_proj1_rsDL: + name: A_TO_proj1_rsDL sender_port: OUTPUT + receiver_port: peer_OUTPUT + sender: A + receiver: proj1_rsDL + proj1_rsDL_TO_C: + name: proj1_rsDL_TO_C + sender_port: I receiver_port: INPUT - sender: A_0 - receiver: C_0 - weight: 1 - Edge B_0 to D_0: - name: Edge B_0 to D_0 + sender: proj1_rsDL + receiver: C + B_TO_proj2_rsDL: + name: B_TO_proj2_rsDL sender_port: OUTPUT + receiver_port: peer_OUTPUT + sender: B + receiver: proj2_rsDL + proj2_rsDL_TO_D: + name: proj2_rsDL_TO_D + sender_port: I receiver_port: INPUT - sender: B_0 - receiver: D_0 - weight: 1 - Edge C_0 to D_0: - name: Edge C_0 to D_0 + sender: proj2_rsDL + receiver: D + C_TO_proj3_rsDL: + name: C_TO_proj3_rsDL sender_port: OUTPUT + receiver_port: peer_OUTPUT + sender: C + receiver: proj3_rsDL + proj3_rsDL_TO_D: + name: proj3_rsDL_TO_D + sender_port: I receiver_port: INPUT - sender: C_0 - receiver: D_0 - weight: 1 + sender: proj3_rsDL + receiver: D diff --git a/examples/NeuroML/ABCD.net.nml b/examples/NeuroML/ABCD.net.nml index 1b5b42d2c..fe25999e1 100644 --- a/examples/NeuroML/ABCD.net.nml +++ b/examples/NeuroML/ABCD.net.nml @@ -1,5 +1,5 @@ - Generated by NeuroMLlite v0.5.3 + Generated by NeuroMLlite v0.5.5 Generated network: ABCD Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/ABCD.nmllite.png b/examples/NeuroML/ABCD.nmllite.png index 0faa617a1..351afe024 100644 Binary files a/examples/NeuroML/ABCD.nmllite.png and b/examples/NeuroML/ABCD.nmllite.png differ diff --git a/examples/NeuroML/FN.gv.png b/examples/NeuroML/FN.gv.png index 32ae53a56..c6d61be82 100644 Binary files a/examples/NeuroML/FN.gv.png and b/examples/NeuroML/FN.gv.png differ diff --git a/examples/NeuroML/FN.json b/examples/NeuroML/FN.json index 59413d82b..8e6a436c3 100644 --- a/examples/NeuroML/FN.json +++ b/examples/NeuroML/FN.json @@ -1,6 +1,6 @@ { "FN": { - "version": "NeuroMLlite v0.5.3", + "version": "NeuroMLlite v0.5.5", "notes": "FitzHugh Nagumo cell model - originally specified in NeuroML/LEMS", "parameters": { "initial_w": 0.0, diff --git a/examples/NeuroML/FN.mdf.json b/examples/NeuroML/FN.mdf.json index e3a00e086..5b3b07c7e 100644 --- a/examples/NeuroML/FN.mdf.json +++ b/examples/NeuroML/FN.mdf.json @@ -1,11 +1,11 @@ { "FN": { - "format": "ModECI MDF v0.3", + "format": "ModECI MDF v0.4", "graphs": { "FN": { "notes": "FitzHugh Nagumo cell model - originally specified in NeuroML/LEMS", "nodes": { - "FNpop_0": { + "FNpop": { "metadata": { "color": "0.2 0.2 0.2", "radius": 3, @@ -13,58 +13,99 @@ }, "parameters": { "initial_w": { - "value": 0.0 + "value": [ + 0.0 + ] }, "initial_v": { - "value": -1.0 + "value": [ + -1.0 + ] }, "a_v": { - "value": -0.3333333333333333 + "value": [ + -0.3333333333333333 + ] }, "b_v": { - "value": 0.0 + "value": [ + 0.0 + ] }, "c_v": { - "value": 1.0 + "value": [ + 1.0 + ] }, "d_v": { - "value": 1.0 + "value": [ + 1.0 + ] }, "e_v": { - "value": -1.0 + "value": [ + -1.0 + ] }, "f_v": { - "value": 1.0 + "value": [ + 1.0 + ] }, "time_constant_v": { - "value": 1.0 + "value": [ + 1.0 + ] }, "a_w": { - "value": 1.0 + "value": [ + 1.0 + ] }, "b_w": { - "value": -0.8 + "value": [ + -0.8 + ] }, "c_w": { - "value": 0.7 + "value": [ + 0.7 + ] }, "time_constant_w": { - "value": 12.5 + "value": [ + 12.5 + ] }, "threshold_exc": { - "value": -1.0 + "value": [ + -1.0 + ] }, "mode": { - "value": 1.0 + "value": [ + 1.0 + ] }, "uncorrelated_activity": { - "value": 0.0 + "value": [ + 0.0 + ] }, "Iext": { - "value": 0.0 + "value": [ + 0.0 + ] }, "MSEC": { - "value": 0.001 + "value": [ + 0.001 + ] + }, + "spike": { + "value": [ + 0 + ] }, "V": { "default_initial_value": "initial_v", @@ -79,6 +120,9 @@ "INPUT": {} }, "output_ports": { + "spike": { + "value": "spike" + }, "V": { "value": "V" }, diff --git a/examples/NeuroML/FN.mdf.yaml b/examples/NeuroML/FN.mdf.yaml index 1d0a94880..2fe6d0350 100644 --- a/examples/NeuroML/FN.mdf.yaml +++ b/examples/NeuroML/FN.mdf.yaml @@ -1,51 +1,72 @@ FN: - format: ModECI MDF v0.3 + format: ModECI MDF v0.4 graphs: FN: notes: FitzHugh Nagumo cell model - originally specified in NeuroML/LEMS nodes: - FNpop_0: + FNpop: metadata: color: 0.2 0.2 0.2 radius: 3 region: region1 parameters: initial_w: - value: 0.0 + value: + - 0.0 initial_v: - value: -1.0 + value: + - -1.0 a_v: - value: -0.3333333333333333 + value: + - -0.3333333333333333 b_v: - value: 0.0 + value: + - 0.0 c_v: - value: 1.0 + value: + - 1.0 d_v: - value: 1.0 + value: + - 1.0 e_v: - value: -1.0 + value: + - -1.0 f_v: - value: 1.0 + value: + - 1.0 time_constant_v: - value: 1.0 + value: + - 1.0 a_w: - value: 1.0 + value: + - 1.0 b_w: - value: -0.8 + value: + - -0.8 c_w: - value: 0.7 + value: + - 0.7 time_constant_w: - value: 12.5 + value: + - 12.5 threshold_exc: - value: -1.0 + value: + - -1.0 mode: - value: 1.0 + value: + - 1.0 uncorrelated_activity: - value: 0.0 + value: + - 0.0 Iext: - value: 0.0 + value: + - 0.0 MSEC: - value: 0.001 + value: + - 0.001 + spike: + value: + - 0 V: default_initial_value: initial_v time_derivative: (a_v*V*V*V + (1+threshold_exc)*b_v*V*V @@ -58,6 +79,8 @@ FN: input_ports: INPUT: {} output_ports: + spike: + value: spike V: value: V W: diff --git a/examples/NeuroML/FN.net.nml b/examples/NeuroML/FN.net.nml index cb3783785..bacd03af7 100644 --- a/examples/NeuroML/FN.net.nml +++ b/examples/NeuroML/FN.net.nml @@ -1,5 +1,5 @@ - Generated by NeuroMLlite v0.5.3 + Generated by NeuroMLlite v0.5.5 Generated network: FN Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/FNmulti.png b/examples/NeuroML/FNmulti.png index 178ac75f9..c4bfab28d 100644 Binary files a/examples/NeuroML/FNmulti.png and b/examples/NeuroML/FNmulti.png differ diff --git a/examples/NeuroML/FNrun.py b/examples/NeuroML/FNrun.py index fbfe00859..6462660ea 100644 --- a/examples/NeuroML/FNrun.py +++ b/examples/NeuroML/FNrun.py @@ -5,6 +5,7 @@ from modelspec.utils import FORMAT_NUMPY, FORMAT_TENSORFLOW import sys +import os import numpy as np verbose = True @@ -52,7 +53,7 @@ def execute(multi=False): id="input_edge", sender=input_node.id, sender_port=op1.id, - receiver="FNpop_0", + receiver="FNpop", receiver_port="INPUT", ) @@ -64,7 +65,9 @@ def execute(multi=False): view_on_render=False, level=3, filename_root="FNmulti", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) duration = 0.1 @@ -87,12 +90,13 @@ def execute(multi=False): else: eg.evaluate(array_format=format, time_increment=dt) - for i in range(len(eg.enodes["FNpop_0"].evaluable_parameters["V"].curr_value)): + for i in range(len(eg.enodes["FNpop"].evaluable_parameters["V"].curr_value)): if not i in vv: vv[i] = [] ww[i] = [] - v = eg.enodes["FNpop_0"].evaluable_parameters["V"].curr_value[i] - w = eg.enodes["FNpop_0"].evaluable_parameters["W"].curr_value[i] + v = eg.enodes["FNpop"].evaluable_parameters["V"].curr_value[i] + w = eg.enodes["FNpop"].evaluable_parameters["W"].curr_value[i] + print(" Time %s: index: %i, V: %s, W: %s" % (t, i, v, w)) vv[i].append(v) ww[i].append(w) if i == 0: @@ -102,8 +106,10 @@ def execute(multi=False): import matplotlib.pyplot as plt for vi in vv: + print(f"Plotting {vi}, {input}") plt.plot(times, vv[vi], label="V %.3f" % input[vi]) plt.plot(times, ww[vi], label="W %.3f" % input[vi]) + plt.legend() if not multi: diff --git a/examples/NeuroML/Izh.png b/examples/NeuroML/Izh.png index 006a2ce49..88f497920 100644 Binary files a/examples/NeuroML/Izh.png and b/examples/NeuroML/Izh.png differ diff --git a/examples/NeuroML/Izh_run.py b/examples/NeuroML/Izh_run.py index c70f5e49d..9e53acd45 100644 --- a/examples/NeuroML/Izh_run.py +++ b/examples/NeuroML/Izh_run.py @@ -5,6 +5,7 @@ from modelspec.utils import FORMAT_NUMPY, FORMAT_TENSORFLOW import sys +import os import numpy as np @@ -16,18 +17,16 @@ def execute(): dt = 0.0005 duration = 0.7 - input_node = mod_graph.get_node("Input_stim_0") - izh_node = mod_graph.get_node("izhPop_0") + input_node = mod_graph.get_node("InputList_stim") + izh_node = mod_graph.get_node("izhPop") num_cells = 1 if not "-iaf" in sys.argv: # for testing... - izh_node.get_parameter("v0").value = [ - izh_node.get_parameter("v0").value - ] * num_cells + izh_node.get_parameter("v0").value = [-0.08] * num_cells izh_node.get_parameter("u").default_initial_value = [0.0] * num_cells izh_node.get_parameter("c").value = [ - izh_node.get_parameter("c").value + izh_node.get_parameter("c").value[0] ] * num_cells input_node.get_parameter("i").conditions[0].value = [0] * num_cells @@ -47,7 +46,9 @@ def execute(): view_on_render=False, level=3, filename_root="Izh", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) verbose = "-v" in sys.argv @@ -71,23 +72,23 @@ def execute(): else: eg.evaluate(array_format=format, time_increment=dt) - for i in range(len(eg.enodes["izhPop_0"].evaluable_parameters["v"].curr_value)): + for i in range(len(eg.enodes["izhPop"].evaluable_parameters["v"].curr_value)): if not i in vv: vv[i] = [] uu[i] = [] ii[i] = [] - v = eg.enodes["izhPop_0"].evaluable_parameters["v"].curr_value[i] - u = eg.enodes["izhPop_0"].evaluable_parameters["u"].curr_value[i] + v = eg.enodes["izhPop"].evaluable_parameters["v"].curr_value[i] + u = eg.enodes["izhPop"].evaluable_parameters["u"].curr_value[i] vv[i].append(v) uu[i].append(u) - ic = eg.enodes["Input_stim_0"].evaluable_parameters["i"].curr_value[i] + ic = eg.enodes[input_node.id].evaluable_parameters["i"].curr_value[i] ii[i].append(ic) print( - f" Value at {t}: v={eg.enodes['izhPop_0'].evaluable_parameters['v'].curr_value }, \ - u={eg.enodes['izhPop_0'].evaluable_parameters['u'].curr_value},\ - i={eg.enodes['Input_stim_0'].evaluable_parameters['i'].curr_value}" + f" Value at {t}: v={eg.enodes['izhPop'].evaluable_parameters['v'].curr_value }, \ + u={eg.enodes['izhPop'].evaluable_parameters['u'].curr_value},\ + i={eg.enodes[input_node.id].evaluable_parameters['i'].curr_value}" ) t += dt diff --git a/examples/NeuroML/IzhikevichTest.gv.png b/examples/NeuroML/IzhikevichTest.gv.png index 953b8c821..71a39af4a 100644 Binary files a/examples/NeuroML/IzhikevichTest.gv.png and b/examples/NeuroML/IzhikevichTest.gv.png differ diff --git a/examples/NeuroML/IzhikevichTest.mdf.json b/examples/NeuroML/IzhikevichTest.mdf.json index d7799d895..b218c3966 100644 --- a/examples/NeuroML/IzhikevichTest.mdf.json +++ b/examples/NeuroML/IzhikevichTest.mdf.json @@ -1,41 +1,76 @@ { "IzhikevichTest": { - "format": "ModECI MDF v0.3", + "format": "ModECI MDF v0.4", "graphs": { "IzhikevichTest": { "notes": "Example Izhikevich", "nodes": { - "izhPop_0": { + "izhPop": { "parameters": { "v0": { - "value": -0.08 + "value": [ + -0.08 + ] }, "C": { - "value": 1e-10 + "value": [ + 1e-10 + ] }, "k": { - "value": 7e-07 + "value": [ + 7e-07 + ] }, "vr": { - "value": -0.06 + "value": [ + -0.06 + ] }, "vt": { - "value": -0.04 + "value": [ + -0.04 + ] }, "vpeak": { - "value": 0.035 + "value": [ + 0.035 + ] }, "a": { - "value": 30.0 + "value": [ + 30.0 + ] }, "b": { - "value": -2e-09 + "value": [ + -2e-09 + ] }, "c": { - "value": -0.05 + "value": [ + -0.05 + ] }, "d": { - "value": 1e-10 + "value": [ + 1e-10 + ] + }, + "spike": { + "default_initial_value": [ + 0 + ], + "conditions": { + "condition_0_on": { + "test": "v > vpeak", + "value": 1 + }, + "condition_0_off": { + "test": "spike > 0", + "value": 0 + } + } }, "v": { "default_initial_value": "v0", @@ -68,6 +103,9 @@ "synapses_i": {} }, "output_ports": { + "spike": { + "value": "spike" + }, "v": { "value": "v" }, @@ -80,16 +118,27 @@ }, "notes": "Cell: [Cell(notes=None, id='izhCell', parameters={'v0': 'v0', 'C': 'C', 'k': 'k', 'vr': 'vr', 'vt': 'vt', 'vpeak': 'vpeak', 'a': 'a', 'b': 'b', 'c': 'c', 'd': 'd'}, neuroml2_source_file=None, lems_source_file=None, neuroml2_cell='izhikevich2007Cell', pynn_cell=None, arbor_cell=None, bindsnet_node=None)] is defined in None and in Lems is: Component, id: izhCell, type: izhikevich2007Cell,\n parameters: {'v0': '-80mV', 'C': '100 pF', 'k': '0.7 nS_per_mV', 'vr': '-60 mV', 'vt': '-40 mV', 'vpeak': '35 mV', 'a': '0.03 per_ms', 'b': '-2 nS', 'c': '-50 mV', 'd': '100 pA'}\n parent: None\n" }, - "Input_stim_0": { + "InputList_stim": { "parameters": { "amplitude": { - "value": 1e-10 + "value": [ + 1e-10 + ] }, "delay": { - "value": 0.1 + "value": [ + 0.1 + ] }, "duration": { - "value": 0.5 + "value": [ + 0.5 + ] + }, + "weight": { + "value": [ + 1 + ] }, "i": { "conditions": { @@ -110,12 +159,16 @@ "t": { "default_initial_value": 0, "time_derivative": "1" - }, - "weight": { - "value": 1 } }, - "input_ports": {}, + "input_ports": { + "spike_input": { + "shape": [ + 1 + ], + "reduce": "add" + } + }, "output_ports": { "i": { "value": "i" @@ -125,12 +178,12 @@ } }, "edges": { - "Edge Input_stim_0 to izhPop_0": { - "name": "Edge Input_stim_0 to izhPop_0", + "Edge InputList_stim to izhPop": { + "name": "Edge InputList_stim to izhPop", "sender_port": "i", "receiver_port": "synapses_i", - "sender": "Input_stim_0", - "receiver": "izhPop_0" + "sender": "InputList_stim", + "receiver": "izhPop" } } } diff --git a/examples/NeuroML/IzhikevichTest.mdf.yaml b/examples/NeuroML/IzhikevichTest.mdf.yaml index d17dcc493..12ef35863 100644 --- a/examples/NeuroML/IzhikevichTest.mdf.yaml +++ b/examples/NeuroML/IzhikevichTest.mdf.yaml @@ -1,31 +1,51 @@ IzhikevichTest: - format: ModECI MDF v0.3 + format: ModECI MDF v0.4 graphs: IzhikevichTest: notes: Example Izhikevich nodes: - izhPop_0: + izhPop: parameters: v0: - value: -0.08 + value: + - -0.08 C: - value: 1.0e-10 + value: + - 1.0e-10 k: - value: 7.0e-07 + value: + - 7.0e-07 vr: - value: -0.06 + value: + - -0.06 vt: - value: -0.04 + value: + - -0.04 vpeak: - value: 0.035 + value: + - 0.035 a: - value: 30.0 + value: + - 30.0 b: - value: -2.0e-09 + value: + - -2.0e-09 c: - value: -0.05 + value: + - -0.05 d: - value: 1.0e-10 + value: + - 1.0e-10 + spike: + default_initial_value: + - 0 + conditions: + condition_0_on: + test: v > vpeak + value: 1 + condition_0_off: + test: spike > 0 + value: 0 v: default_initial_value: v0 conditions: @@ -47,6 +67,8 @@ IzhikevichTest: input_ports: synapses_i: {} output_ports: + spike: + value: spike v: value: v u: @@ -63,14 +85,20 @@ IzhikevichTest: \ 'C': '100 pF', 'k': '0.7 nS_per_mV', 'vr': '-60 mV', 'vt':\ \ '-40 mV', 'vpeak': '35 mV', 'a': '0.03 per_ms', 'b': '-2\ \ nS', 'c': '-50 mV', 'd': '100 pA'}\n parent: None\n" - Input_stim_0: + InputList_stim: parameters: amplitude: - value: 1.0e-10 + value: + - 1.0e-10 delay: - value: 0.1 + value: + - 0.1 duration: - value: 0.5 + value: + - 0.5 + weight: + value: + - 1 i: conditions: condition_0: @@ -85,9 +113,11 @@ IzhikevichTest: t: default_initial_value: 0 time_derivative: '1' - weight: - value: 1 - input_ports: {} + input_ports: + spike_input: + shape: + - 1 + reduce: add output_ports: i: value: i @@ -99,9 +129,9 @@ IzhikevichTest: \ '100pA', 'delay': '100ms', 'duration': '500ms'}\n parent:\ \ None\n" edges: - Edge Input_stim_0 to izhPop_0: - name: Edge Input_stim_0 to izhPop_0 + Edge InputList_stim to izhPop: + name: Edge InputList_stim to izhPop sender_port: i receiver_port: synapses_i - sender: Input_stim_0 - receiver: izhPop_0 + sender: InputList_stim + receiver: izhPop diff --git a/examples/NeuroML/IzhikevichTest.net.nml b/examples/NeuroML/IzhikevichTest.net.nml index a998e8ad7..8eb844232 100644 --- a/examples/NeuroML/IzhikevichTest.net.nml +++ b/examples/NeuroML/IzhikevichTest.net.nml @@ -1,5 +1,5 @@ - Generated by NeuroMLlite v0.5.3 + Generated by NeuroMLlite v0.5.5 Generated network: IzhikevichTest Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/IzhikevichTest.nmllite.yaml b/examples/NeuroML/IzhikevichTest.nmllite.yaml index c2f0afbb0..9865e8784 100644 --- a/examples/NeuroML/IzhikevichTest.nmllite.yaml +++ b/examples/NeuroML/IzhikevichTest.nmllite.yaml @@ -1,5 +1,5 @@ IzhikevichTest: - version: NeuroMLlite v0.5.3 + version: NeuroMLlite v0.5.5 notes: Example Izhikevich parameters: N: 1 diff --git a/examples/NeuroML/LEMS_SimABCD.png b/examples/NeuroML/LEMS_SimABCD.png index 3f3bd62bb..0906f4863 100644 Binary files a/examples/NeuroML/LEMS_SimABCD.png and b/examples/NeuroML/LEMS_SimABCD.png differ diff --git a/examples/NeuroML/LEMS_SimABCD.xml b/examples/NeuroML/LEMS_SimABCD.xml index 86b9d1eba..b4fd77efd 100644 --- a/examples/NeuroML/LEMS_SimABCD.xml +++ b/examples/NeuroML/LEMS_SimABCD.xml @@ -2,7 +2,7 @@ diff --git a/examples/NeuroML/LEMS_SimFN.png b/examples/NeuroML/LEMS_SimFN.png index eba8406ef..2b558ab55 100644 Binary files a/examples/NeuroML/LEMS_SimFN.png and b/examples/NeuroML/LEMS_SimFN.png differ diff --git a/examples/NeuroML/LEMS_SimFN.xml b/examples/NeuroML/LEMS_SimFN.xml index b8d74ec21..e3ae57645 100644 --- a/examples/NeuroML/LEMS_SimFN.xml +++ b/examples/NeuroML/LEMS_SimFN.xml @@ -2,7 +2,7 @@ diff --git a/examples/NeuroML/LEMS_SimIzhikevichTest.png b/examples/NeuroML/LEMS_SimIzhikevichTest.png index 2dbcc2b52..51b9a82ce 100644 Binary files a/examples/NeuroML/LEMS_SimIzhikevichTest.png and b/examples/NeuroML/LEMS_SimIzhikevichTest.png differ diff --git a/examples/NeuroML/LEMS_SimIzhikevichTest.xml b/examples/NeuroML/LEMS_SimIzhikevichTest.xml index 0494c1b03..1bf4ac597 100644 --- a/examples/NeuroML/LEMS_SimIzhikevichTest.xml +++ b/examples/NeuroML/LEMS_SimIzhikevichTest.xml @@ -2,7 +2,7 @@ diff --git a/examples/NeuroML/MDFFNrun.multi.png b/examples/NeuroML/MDFFNrun.multi.png index 9e31dec82..0ca380dbd 100644 Binary files a/examples/NeuroML/MDFFNrun.multi.png and b/examples/NeuroML/MDFFNrun.multi.png differ diff --git a/examples/NeuroML/SimABCD.json b/examples/NeuroML/SimABCD.json index 3b2dad8a5..35bf02eb3 100644 --- a/examples/NeuroML/SimABCD.json +++ b/examples/NeuroML/SimABCD.json @@ -1,6 +1,6 @@ { "SimABCD": { - "version": "NeuroMLlite v0.5.3", + "version": "NeuroMLlite v0.5.5", "network": "ABCD.json", "duration": 5000.0, "dt": 100.0, diff --git a/examples/NeuroML/SimFN.json b/examples/NeuroML/SimFN.json index 57008b4f6..cc8efc22c 100644 --- a/examples/NeuroML/SimFN.json +++ b/examples/NeuroML/SimFN.json @@ -1,6 +1,6 @@ { "SimFN": { - "version": "NeuroMLlite v0.5.3", + "version": "NeuroMLlite v0.5.5", "network": "FN.json", "duration": 100.0, "dt": 0.05, diff --git a/examples/NeuroML/SimIzhikevichTest.yaml b/examples/NeuroML/SimIzhikevichTest.yaml index 7476f51de..aa52243c0 100644 --- a/examples/NeuroML/SimIzhikevichTest.yaml +++ b/examples/NeuroML/SimIzhikevichTest.yaml @@ -1,5 +1,5 @@ SimIzhikevichTest: - version: NeuroMLlite v0.5.3 + version: NeuroMLlite v0.5.5 network: IzhikevichTest.nmllite.yaml duration: 700.0 dt: 0.025 diff --git a/examples/NeuroML/regenerateAndTest.sh b/examples/NeuroML/regenerateAndTest.sh index b6529b508..1213237a7 100755 --- a/examples/NeuroML/regenerateAndTest.sh +++ b/examples/NeuroML/regenerateAndTest.sh @@ -59,6 +59,7 @@ python -m modeci_mdf.interfaces.graphviz.exporter FN.mdf.yaml 3 -noview python -m modeci_mdf.execution_engine FN.mdf.json #### Test running MDF version & save result +python FNrun.py -multi -nogui python FNrun.py -nogui diff --git a/examples/ONNX/ab.json b/examples/ONNX/ab.json index 260b05f57..d1531090e 100644 --- a/examples/ONNX/ab.json +++ b/examples/ONNX/ab.json @@ -1,7 +1,7 @@ { "ONNX Model": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "torch-jit-export": { "nodes": { diff --git a/examples/ONNX/ab.png b/examples/ONNX/ab.png index 62e7ceb59..7b76243db 100644 Binary files a/examples/ONNX/ab.png and b/examples/ONNX/ab.png differ diff --git a/examples/ONNX/ab.yaml b/examples/ONNX/ab.yaml index d550284eb..68d142f0c 100644 --- a/examples/ONNX/ab.yaml +++ b/examples/ONNX/ab.yaml @@ -1,6 +1,6 @@ ONNX Model: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: torch-jit-export: nodes: diff --git a/examples/ONNX/abc.json b/examples/ONNX/abc.json index 448106226..28595e844 100644 --- a/examples/ONNX/abc.json +++ b/examples/ONNX/abc.json @@ -1,7 +1,7 @@ { "ONNX Model": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "torch-jit-export": { "nodes": { diff --git a/examples/ONNX/abc.yaml b/examples/ONNX/abc.yaml index 6ea175c98..53672ce76 100644 --- a/examples/ONNX/abc.yaml +++ b/examples/ONNX/abc.yaml @@ -1,6 +1,6 @@ ONNX Model: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: torch-jit-export: nodes: diff --git a/examples/ONNX/abcd.json b/examples/ONNX/abcd.json index e2ffef042..a234236dd 100644 --- a/examples/ONNX/abcd.json +++ b/examples/ONNX/abcd.json @@ -1,7 +1,7 @@ { "ONNX Model": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "torch-jit-export": { "nodes": { diff --git a/examples/ONNX/abcd.yaml b/examples/ONNX/abcd.yaml index 625476526..7da067acb 100644 --- a/examples/ONNX/abcd.yaml +++ b/examples/ONNX/abcd.yaml @@ -1,6 +1,6 @@ ONNX Model: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: torch-jit-export: nodes: diff --git a/examples/ONNX/simple_ab.py b/examples/ONNX/simple_ab.py index da06f6f34..105dbac50 100644 --- a/examples/ONNX/simple_ab.py +++ b/examples/ONNX/simple_ab.py @@ -7,6 +7,7 @@ import torch import onnx import sys +import os from modeci_mdf.interfaces.onnx import onnx_to_mdf @@ -80,7 +81,9 @@ def main(): view_on_render=False, level=3, filename_root="ab", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) if "-run" in sys.argv: verbose = True diff --git a/examples/ONNX/simple_abc.py b/examples/ONNX/simple_abc.py index 1adbdfc25..4ce3cd401 100644 --- a/examples/ONNX/simple_abc.py +++ b/examples/ONNX/simple_abc.py @@ -6,6 +6,7 @@ """ import torch import onnx +import os from modeci_mdf.interfaces.onnx import onnx_to_mdf @@ -76,14 +77,16 @@ def main(): mdf_model.to_json_file("abc.json") mdf_model.to_yaml_file("abc.yaml") + """ + Can't be exported to graph as Loop not supported... mdf_model.to_graph_image( engine="dot", output_format="png", view_on_render=False, level=3, filename_root="abc", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions - ) + only_warn_on_fail= (os.name=='nt'), # Makes sure test of this doesn't fail on Windows on GitHub Actions + )""" if __name__ == "__main__": diff --git a/examples/PyTorch/MDF_PyTorch/ABCD_pytorch.py b/examples/PyTorch/MDF_PyTorch/ABCD_pytorch.py index dfda7dc1e..4e68aad8f 100644 --- a/examples/PyTorch/MDF_PyTorch/ABCD_pytorch.py +++ b/examples/PyTorch/MDF_PyTorch/ABCD_pytorch.py @@ -1,5 +1,5 @@ """ -This script has been generated by modeci_mdf v0.4.5. +This script has been generated by modeci_mdf v0.4.6. It is an export of a MDF model (mdf.s - MDF stateful, i.e. full MDF allowing stateful parameters) to PyTorch """ diff --git a/examples/PyTorch/MDF_PyTorch/Arrays_pytorch.py b/examples/PyTorch/MDF_PyTorch/Arrays_pytorch.py index d776c44bf..446366331 100644 --- a/examples/PyTorch/MDF_PyTorch/Arrays_pytorch.py +++ b/examples/PyTorch/MDF_PyTorch/Arrays_pytorch.py @@ -1,5 +1,5 @@ """ -This script has been generated by modeci_mdf v0.4.5. +This script has been generated by modeci_mdf v0.4.6. It is an export of a MDF model (mdf.s - MDF stateful, i.e. full MDF allowing stateful parameters) to PyTorch """ diff --git a/examples/PyTorch/MDF_PyTorch/Simple_pytorch.py b/examples/PyTorch/MDF_PyTorch/Simple_pytorch.py index 1cee63fef..8b3f2e045 100644 --- a/examples/PyTorch/MDF_PyTorch/Simple_pytorch.py +++ b/examples/PyTorch/MDF_PyTorch/Simple_pytorch.py @@ -1,5 +1,5 @@ """ -This script has been generated by modeci_mdf v0.4.5. +This script has been generated by modeci_mdf v0.4.6. It is an export of a MDF model (mdf.s - MDF stateful, i.e. full MDF allowing stateful parameters) to PyTorch """ diff --git a/examples/PyTorch/inception.json b/examples/PyTorch/inception.json index 30a48aa84..5d555af27 100644 --- a/examples/PyTorch/inception.json +++ b/examples/PyTorch/inception.json @@ -1,7 +1,7 @@ { "InceptionBlocks": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "InceptionBlocksGraph": { "nodes": { diff --git a/examples/PyTorch/inception.png b/examples/PyTorch/inception.png index 828201e86..ed468c27f 100644 Binary files a/examples/PyTorch/inception.png and b/examples/PyTorch/inception.png differ diff --git a/examples/PyTorch/inception.py b/examples/PyTorch/inception.py index 71bc3ec47..fd974c3ff 100644 --- a/examples/PyTorch/inception.py +++ b/examples/PyTorch/inception.py @@ -1,5 +1,6 @@ import numpy as np import torch +import os import torch.nn as nn from modeci_mdf.interfaces.pytorch import pytorch_to_mdf @@ -309,7 +310,9 @@ def main(): view_on_render=False, level=1, filename_root="inception", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions is_horizontal=True, solid_color=True, ) diff --git a/examples/PyTorch/mlp_pure_mdf.json b/examples/PyTorch/mlp_pure_mdf.json index b3cb2ae11..23b34c326 100644 --- a/examples/PyTorch/mlp_pure_mdf.json +++ b/examples/PyTorch/mlp_pure_mdf.json @@ -1,7 +1,7 @@ { "mlp_pure_mdf": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "mlp_pure_mdf": { "nodes": { diff --git a/examples/PyTorch/mlp_pure_mdf.png b/examples/PyTorch/mlp_pure_mdf.png index df5d21ce8..4267ec857 100644 Binary files a/examples/PyTorch/mlp_pure_mdf.png and b/examples/PyTorch/mlp_pure_mdf.png differ diff --git a/examples/PyTorch/mlp_pure_mdf.py b/examples/PyTorch/mlp_pure_mdf.py index a660bfa2e..bb8df955b 100644 --- a/examples/PyTorch/mlp_pure_mdf.py +++ b/examples/PyTorch/mlp_pure_mdf.py @@ -4,6 +4,7 @@ import sys import h5py import time +import os # Note: the weights for this model were precomputed and saved in the file weights.h5 def get_weight_info(): @@ -202,7 +203,9 @@ def main(): view_on_render=False, level=2, filename_root="mlp_pure_mdf", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) if test_all: diff --git a/examples/PyTorch/mlp_pure_mdf.yaml b/examples/PyTorch/mlp_pure_mdf.yaml index 10a296af0..b14b3e54b 100644 --- a/examples/PyTorch/mlp_pure_mdf.yaml +++ b/examples/PyTorch/mlp_pure_mdf.yaml @@ -1,6 +1,6 @@ mlp_pure_mdf: format: ModECI MDF v0.4 - generating_application: Python modeci-mdf v0.4.5 + generating_application: Python modeci-mdf v0.4.6 graphs: mlp_pure_mdf: nodes: diff --git a/examples/PyTorch/pytorch_ddm.py b/examples/PyTorch/pytorch_ddm.py index 0e7eb9ce0..f0104ed0b 100644 --- a/examples/PyTorch/pytorch_ddm.py +++ b/examples/PyTorch/pytorch_ddm.py @@ -2,6 +2,7 @@ import time import re +import os import torch from torch import nn @@ -90,7 +91,9 @@ def main(): view_on_render=False, level=2, filename_root="ddm", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) diff --git a/examples/PyTorch/run_translated_mlp_pure_mdf.py b/examples/PyTorch/run_translated_mlp_pure_mdf.py index 4e0ac7b58..e245a73d0 100644 --- a/examples/PyTorch/run_translated_mlp_pure_mdf.py +++ b/examples/PyTorch/run_translated_mlp_pure_mdf.py @@ -11,7 +11,7 @@ import argparse import sys import numpy as np -import sys +import os import h5py import time @@ -57,7 +57,9 @@ def main(): view_on_render=False, level=2, filename_root="mlp_pure_mdf", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions ) if test_all: diff --git a/examples/PyTorch/simple_pytorch_to_mdf.1.png b/examples/PyTorch/simple_pytorch_to_mdf.1.png index 90fa4a086..6e28015c1 100644 Binary files a/examples/PyTorch/simple_pytorch_to_mdf.1.png and b/examples/PyTorch/simple_pytorch_to_mdf.1.png differ diff --git a/examples/PyTorch/simple_pytorch_to_mdf.json b/examples/PyTorch/simple_pytorch_to_mdf.json index e6eb73cd9..6e2317a13 100644 --- a/examples/PyTorch/simple_pytorch_to_mdf.json +++ b/examples/PyTorch/simple_pytorch_to_mdf.json @@ -1,7 +1,7 @@ { "SimpleNet": { "format": "ModECI MDF v0.4", - "generating_application": "Python modeci-mdf v0.4.5", + "generating_application": "Python modeci-mdf v0.4.6", "graphs": { "SimpleNetGraph": { "nodes": { diff --git a/examples/PyTorch/simple_pytorch_to_mdf.png b/examples/PyTorch/simple_pytorch_to_mdf.png index 6e94fccaa..3749fcb67 100644 Binary files a/examples/PyTorch/simple_pytorch_to_mdf.png and b/examples/PyTorch/simple_pytorch_to_mdf.png differ diff --git a/examples/PyTorch/simple_pytorch_to_mdf.py b/examples/PyTorch/simple_pytorch_to_mdf.py index adbcfd3b7..7c59dabfe 100644 --- a/examples/PyTorch/simple_pytorch_to_mdf.py +++ b/examples/PyTorch/simple_pytorch_to_mdf.py @@ -7,6 +7,7 @@ from torchviz import make_dot import netron from modeci_mdf.interfaces.pytorch import pytorch_to_mdf +import os class SimpleNet(nn.Module): @@ -101,7 +102,9 @@ def main(): view_on_render=False, level=1, filename_root="simple_pytorch_to_mdf.1", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions is_horizontal=True, solid_color=True, ) @@ -111,7 +114,9 @@ def main(): view_on_render=False, level=3, filename_root="simple_pytorch_to_mdf", - only_warn_on_fail=True, # Makes sure test of this doesn't fail on Windows on GitHub Actions + only_warn_on_fail=( + os.name == "nt" + ), # Makes sure test of this doesn't fail on Windows on GitHub Actions solid_color=False, ) # export to PyTorch graph diff --git a/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png b/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png index 599c2049c..561d0b870 100644 Binary files a/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png and b/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png differ diff --git a/setup.cfg b/setup.cfg index 5544b183a..c7474160c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,8 +40,9 @@ install_requires = matplotlib graphviz h5py - onnxruntime<=1.13.1,>=1.12.0 - skl2onnx>=1.13 + onnxruntime==1.13.1 + onnx==1.12.0 + skl2onnx==1.14.0 attrs>=21.1.0 cattrs modelspec<0.3,>=0.2.6 diff --git a/src/modeci_mdf/__init__.py b/src/modeci_mdf/__init__.py index 6874bd3f9..0cd984e0c 100644 --- a/src/modeci_mdf/__init__.py +++ b/src/modeci_mdf/__init__.py @@ -13,4 +13,4 @@ MODECI_MDF_VERSION = "0.4" # Version of the Python module. -__version__ = "0.4.5" +__version__ = "0.4.6" diff --git a/src/modeci_mdf/mdf.py b/src/modeci_mdf/mdf.py index 69c6ca19e..bf7b4dacd 100644 --- a/src/modeci_mdf/mdf.py +++ b/src/modeci_mdf/mdf.py @@ -193,13 +193,13 @@ def summary(self): self.value, self.is_stateful(), ) - if self.default_initial_value: + if self.default_initial_value is not None: info += f", def init: {self.default_initial_value}" - if self.time_derivative: + if self.time_derivative is not None: info += f", time deriv: {self.time_derivative}" - if self.conditions: + if self.conditions is not None: for c in self.conditions: info += f", {c}" diff --git a/test_all.sh b/test_all.sh index 61197b133..5271ea6d1 100755 --- a/test_all.sh +++ b/test_all.sh @@ -93,3 +93,5 @@ python addition.py cd ../../docs python generate.py cd .. + +pre-commit run --all-files