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/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png b/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png index 1003fa49c..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 187889491..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 b35d746dd..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 c1ffcb879..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 e84b4e178..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 2295de8d4..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 0b79e9317..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 730b03a73..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 4e67de5ef..eca473dc5 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 937e9853d..84b763664 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 6b7096bf5..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 14d0e939a..1d86d21ed 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..5a2681465 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 1c700f93e..89225233e 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 e0484c66a..1dcf2d0e4 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 3ebbd1167..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 e6a2f6385..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 f436a54b2..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 896f36543..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 6c22adf70..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 e47816d36..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 425a0d5b7..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 49a7cfa5b..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 a6e12acaa..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/MDF/Arrays.json b/examples/MDF/Arrays.json index 23dfaec89..c0435c447 100644 --- a/examples/MDF/Arrays.json +++ b/examples/MDF/Arrays.json @@ -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..bab803614 100644 --- a/examples/MDF/Arrays.yaml +++ b/examples/MDF/Arrays.yaml @@ -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/RNN/IAF_net.json b/examples/MDF/RNN/IAF_net.json index 22a9b8639..a2c54994b 100644 --- a/examples/MDF/RNN/IAF_net.json +++ b/examples/MDF/RNN/IAF_net.json @@ -46,7 +46,7 @@ } }, "output_ports": { - "out_port": { + "current_output": { "value": "level" } } @@ -57,17 +57,9 @@ "shape": [ 8 ] - }, - "spike_input": { - "shape": [ - 8 - ] } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ -54.67038134416407, @@ -107,108 +99,6 @@ -20 ] }, - "spike_weights": { - "value": [ - [ - 1.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, - 1.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, - 1.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, - 1.0, - 0.0 - ], - [ - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.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" - } - ] - }, "spiking": { "default_initial_value": "0", "conditions": [ @@ -226,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", @@ -237,10 +127,10 @@ } }, "output_ports": { - "out_port_v": { + "v_output": { "value": "v" }, - "out_port_spiking": { + "spiking_output": { "value": "spiking" } } @@ -251,17 +141,9 @@ "shape": [ 8 ] - }, - "spike_input": { - "shape": [ - 8 - ] } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ -54.67038134416407, @@ -301,6 +183,54 @@ -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": [ [ @@ -402,40 +332,11 @@ "value": "weighted_spike" } ] - }, - "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 + syn_i + current_input", - "conditions": [ - { - "id": "reset", - "test": "v > thresh", - "value": "erev" - } - ] } }, "output_ports": { - "out_port_v": { - "value": "v" - }, - "out_port_spiking": { - "value": "spiking" + "current_output": { + "value": "syn_i" } } } @@ -444,13 +345,19 @@ "input_edge": { "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" }, "syn_edge": { "sender": "pre", - "receiver": "post", - "sender_port": "out_port_spiking", + "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 0209e8ab3..b7645fdfb 100644 --- a/examples/MDF/RNN/IAF_net.yaml +++ b/examples/MDF/RNN/IAF_net.yaml @@ -33,19 +33,14 @@ IAF_net: test: time > start + duration value: amplitude*0 output_ports: - out_port: + current_output: value: level pre: input_ports: current_input: shape: - 8 - spike_input: - shape: - - 8 parameters: - syn_tau: - value: 10 v0: value: - -54.67038134416407 @@ -78,84 +73,6 @@ IAF_net: - -20 - -20 - -20 - spike_weights: - value: - - - 1.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 - - 1.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 - - 1.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 - - 1.0 - - 0.0 - - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 1.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 spiking: default_initial_value: '0' conditions: @@ -167,27 +84,22 @@ 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: shape: - 8 - spike_input: - shape: - - 8 parameters: - syn_tau: - value: 10 v0: value: - -54.67038134416407 @@ -220,6 +132,35 @@ IAF_net: - -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: - - 40.0 @@ -298,35 +239,22 @@ IAF_net: - id: spike_detected test: spike_input > 0 value: weighted_spike - 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 + syn_i + current_input - conditions: - - id: reset - test: v > thresh - value: erev output_ports: - out_port_v: - value: v - out_port_spiking: - value: spiking + current_output: + value: syn_i edges: input_edge: 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 syn_edge: sender: pre - receiver: post - sender_port: out_port_spiking + receiver: syn_post + sender_port: spiking_output receiver_port: spike_input diff --git a/examples/MDF/RNN/IAF_net2.json b/examples/MDF/RNN/IAF_net2.json index 1f4123c43..d5f2d486a 100644 --- a/examples/MDF/RNN/IAF_net2.json +++ b/examples/MDF/RNN/IAF_net2.json @@ -55,7 +55,7 @@ } }, "output_ports": { - "out_port": { + "current_output": { "value": "level" } } @@ -66,17 +66,9 @@ "shape": [ 8 ] - }, - "spike_input": { - "shape": [ - 8 - ] } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ -70, @@ -116,108 +108,6 @@ -20 ] }, - "spike_weights": { - "value": [ - [ - 1.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, - 1.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, - 1.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, - 1.0, - 0.0 - ], - [ - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.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" - } - ] - }, "spiking": { "default_initial_value": "0", "conditions": [ @@ -235,7 +125,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", @@ -246,10 +136,10 @@ } }, "output_ports": { - "out_port_v": { + "v_output": { "value": "v" }, - "out_port_spiking": { + "spiking_output": { "value": "spiking" } } @@ -260,17 +150,9 @@ "shape": [ 8 ] - }, - "spike_input": { - "shape": [ - 8 - ] } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ -70, @@ -310,6 +192,54 @@ -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": [ [ @@ -411,40 +341,11 @@ "value": "weighted_spike" } ] - }, - "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 + syn_i + current_input", - "conditions": [ - { - "id": "reset", - "test": "v > thresh", - "value": "erev" - } - ] } }, "output_ports": { - "out_port_v": { - "value": "v" - }, - "out_port_spiking": { - "value": "spiking" + "current_output": { + "value": "syn_i" } } } @@ -453,13 +354,19 @@ "input_edge": { "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" }, "syn_edge": { "sender": "pre", - "receiver": "post", - "sender_port": "out_port_spiking", + "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 index 67ebb5377..ce90e1201 100644 --- a/examples/MDF/RNN/IAF_net2.yaml +++ b/examples/MDF/RNN/IAF_net2.yaml @@ -41,19 +41,14 @@ IAF_net2: test: time > start + duration value: amplitude*0 output_ports: - out_port: + current_output: value: level pre: input_ports: current_input: shape: - 8 - spike_input: - shape: - - 8 parameters: - syn_tau: - value: 10 v0: value: - -70 @@ -86,84 +81,6 @@ IAF_net2: - -20 - -20 - -20 - spike_weights: - value: - - - 1.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 - - 1.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 - - 1.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 - - 1.0 - - 0.0 - - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 0.0 - - 1.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 spiking: default_initial_value: '0' conditions: @@ -175,27 +92,22 @@ IAF_net2: 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: shape: - 8 - spike_input: - shape: - - 8 parameters: - syn_tau: - value: 10 v0: value: - -70 @@ -228,6 +140,35 @@ IAF_net2: - -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 @@ -306,35 +247,22 @@ IAF_net2: - id: spike_detected test: spike_input > 0 value: weighted_spike - 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 + syn_i + current_input - conditions: - - id: reset - test: v > thresh - value: erev output_ports: - out_port_v: - value: v - out_port_spiking: - value: spiking + current_output: + value: syn_i edges: input_edge: 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 syn_edge: sender: pre - receiver: post - sender_port: out_port_spiking + 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 01992beea..55508ee93 100644 --- a/examples/MDF/RNN/IAFs.json +++ b/examples/MDF/RNN/IAFs.json @@ -37,7 +37,7 @@ } }, "output_ports": { - "out_port": { + "current_output": { "value": "level" } } @@ -48,17 +48,9 @@ "shape": [ 1 ] - }, - "spike_input": { - "shape": [ - 1 - ] } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ -60 @@ -77,31 +69,6 @@ -20 ] }, - "spike_weights": { - "value": [ - [ - 1.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" - } - ] - }, "spiking": { "default_initial_value": "0", "conditions": [ @@ -119,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", @@ -130,10 +97,10 @@ } }, "output_ports": { - "out_port_v": { + "v_output": { "value": "v" }, - "out_port_spiking": { + "spiking_output": { "value": "spiking" } } @@ -144,17 +111,9 @@ "shape": [ 1 ] - }, - "spike_input": { - "shape": [ - 1 - ] } }, "parameters": { - "syn_tau": { - "value": 10 - }, "v0": { "value": [ -60 @@ -173,29 +132,6 @@ -20 ] }, - "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" - } - ] - }, "spiking": { "default_initial_value": "0", "conditions": [ @@ -213,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", @@ -224,26 +160,74 @@ } }, "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": "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" }, "syn_edge": { "sender": "pre", - "receiver": "post", - "sender_port": "out_port_spiking", + "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 0549aaec1..ac8de32a1 100644 --- a/examples/MDF/RNN/IAFs.yaml +++ b/examples/MDF/RNN/IAFs.yaml @@ -25,19 +25,14 @@ IAFs: test: time > start + duration value: amplitude*0 output_ports: - out_port: + current_output: value: level pre: input_ports: current_input: shape: - 1 - spike_input: - shape: - - 1 parameters: - syn_tau: - value: 10 v0: value: - -60 @@ -49,21 +44,6 @@ IAFs: thresh: value: - -20 - spike_weights: - value: - - - 1.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 spiking: default_initial_value: '0' conditions: @@ -75,27 +55,22 @@ 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: shape: - 1 - spike_input: - shape: - - 1 parameters: - syn_tau: - value: 10 v0: value: - -60 @@ -107,21 +82,6 @@ IAFs: thresh: value: - -20 - 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 spiking: default_initial_value: '0' conditions: @@ -133,24 +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: 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 syn_edge: sender: pre - receiver: post - sender_port: out_port_spiking + receiver: syn_post + sender_port: spiking_output receiver_port: spike_input diff --git a/examples/MDF/RNN/IaF.net.run.png b/examples/MDF/RNN/IaF.net.run.png index 514495c4b..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 index 6adbb47fc..900751bd7 100644 Binary files a/examples/MDF/RNN/IaF.net2.run.png 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 5289b6c16..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/RNNs.json b/examples/MDF/RNN/RNNs.json index 40008a533..cc2b35784 100644 --- a/examples/MDF/RNN/RNNs.json +++ b/examples/MDF/RNN/RNNs.json @@ -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..12c591c63 100644 --- a/examples/MDF/RNN/RNNs.yaml +++ b/examples/MDF/RNN/RNNs.yaml @@ -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 da1fae47c..42b4ec8fe 100644 --- a/examples/MDF/RNN/generate_iaf.py +++ b/examples/MDF/RNN/generate_iaf.py @@ -4,28 +4,96 @@ from modeci_mdf.mdf import * import sys +import os import numpy import random random.seed(1234) -def create_iaf_node( - id, num_cells=1, v0=-60, erev=-70, thresh=-20, tau=10.0, syn_tau=10 +def create_current_pulse_node(id, start=20, duration=60, amplitude=10): + + ## Current input node + current_pulse_node = Node(id=id) + + t_param = Parameter(id="time", default_initial_value=0, time_derivative="1") + current_pulse_node.parameters.append(t_param) + + start = Parameter(id="start", value=start) + current_pulse_node.parameters.append(start) + + dur = Parameter(id="duration", value=duration) + current_pulse_node.parameters.append(dur) + + amp = Parameter(id="amplitude", value=amplitude) + current_pulse_node.parameters.append(amp) + + level = Parameter(id="level", value=0) + + 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" + ) + ) + + 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) - ip_spike = InputPort(id="spike_input", shape="(%i,)" % num_cells) - iaf_node.input_ports.append(ip_spike) - - syn_tau = Parameter(id="syn_tau", value=syn_tau) - iaf_node.parameters.append(syn_tau) - v0 = Parameter( id="v0", value=numpy.array([v0] * num_cells) if isinstance(v0, (int, float)) else v0, @@ -41,30 +109,6 @@ def create_iaf_node( thresh = Parameter(id="thresh", value=numpy.array([thresh] * num_cells)) iaf_node.parameters.append(thresh) - spike_weights = Parameter(id="spike_weights", value=numpy.identity(num_cells)) - iaf_node.parameters.append(spike_weights) - - weighted_spike = Parameter( - id="weighted_spike", - function="MatMul", - args={"A": spike_weights.id, "B": ip_spike.id}, - ) - iaf_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) - iaf_node.parameters.append(syn_i) - pc1 = ParameterCondition(id="is_spiking", test="v >= thresh", value="1") pc2 = ParameterCondition(id="not_spiking", test="v < thresh", value="0") @@ -81,19 +125,31 @@ def create_iaf_node( 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) - return iaf_node + 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, syn_node, internal_edge + else: + return iaf_node def main(): @@ -101,59 +157,51 @@ def main(): 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" - num_cells = 8 if net or net2 else 1 + some_net = net or net2 or net3 + + num_cells = 8 if net or net2 else (1 if net3 else 1) mod_graph = Graph(id="iaf_example") mod.graphs.append(mod_graph) - ## Current input node - input_node = Node(id="current_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)]) + amplitude = numpy.array([random.random() * 20 for r in range(num_cells)]) if net2: - amp.value = 15 - start.value = numpy.arange(10, 10 * (num_cells + 1), 10) - dur.value = numpy.ones(num_cells) * 5 + 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) - level = Parameter(id="level", value=0) + if net3: + amplitude = 10 + start = 20 + duration = 10 - 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" - ) + input_node = create_current_pulse_node( + "current_input_node", start, duration, amplitude ) - 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) + if net3: + input_node2 = create_current_pulse_node("current_input_node2", 60, 10, 3) + mod_graph.nodes.append(input_node2) + v0 = ( numpy.array([random.random() * 20 - 70 for r in range(num_cells)]) if net @@ -162,14 +210,14 @@ def main(): else -60 ) - iaf_node1 = create_iaf_node("pre", num_cells, v0) + 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", 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, ) @@ -177,8 +225,23 @@ def main(): mod_graph.edges.append(e1) mod_graph.nodes.append(iaf_node1) - iaf_node2 = create_iaf_node("post", num_cells, v0) + 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 @@ -191,14 +254,14 @@ def main(): for i in range(num_cells): weight[i, i] = i - iaf_node2.get_parameter("spike_weights").value = weight + syn_node2.get_parameter("spike_weights").value = weight e2 = Edge( id="syn_edge", 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) @@ -215,9 +278,12 @@ def main(): 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 @@ -237,20 +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) - print( - " Out v: %s" - % eg.enodes["post"].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["out_port"].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["out_port_v"].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 @@ -260,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 = [] @@ -271,7 +342,7 @@ def main(): else: axis[0].plot(times, i, label="Input node current", color="k") - if not (net or net2): + if not some_net: axis[0].legend() if type(s1[0]) == numpy.ndarray and s1[0].size > 1: @@ -283,7 +354,7 @@ def main(): else: axis[1].plot(times, s1, label="IaF pre v", color="r") - if not (net or net2): + if not some_net: axis[1].legend() if type(s2[0]) == numpy.ndarray and s2[0].size > 1: @@ -295,7 +366,7 @@ def main(): else: axis[2].plot(times, s2, label="IaF post v", color="b") - if not (net or net2): + if not some_net: axis[2].legend() if type(sp1[0]) == numpy.ndarray and sp1[0].size > 1: @@ -306,7 +377,12 @@ def main(): nz = [t * dt for t in numpy.nonzero(sps1)][0] 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])): @@ -321,6 +397,7 @@ def main(): marker=".", color="b", linewidth=0, + markersize=markersize, ) else: nz1 = [t * dt for t in numpy.nonzero(sp1)][0] @@ -349,7 +426,12 @@ def main(): plt.xlabel("Time") plt.savefig( - "IaF%s.run.png" % (".net" if (net) else (".net2" if (net2) else "")), + "IaF%s.run.png" + % ( + ".net" + if (net) + else (".net2" if (net2) else (".net3" if (net3) else "")) + ), bbox_inches="tight", ) @@ -362,9 +444,16 @@ def main(): output_format="png", view_on_render=False, level=2, - filename_root="iaf%s" % (".net" if (net) else (".net2" if (net2) else "")), + 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 index 659b68a0f..0fea0853a 100644 Binary files a/examples/MDF/RNN/iaf.net.png 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 index f726cbb47..b86488593 100644 Binary files a/examples/MDF/RNN/iaf.net2.png and b/examples/MDF/RNN/iaf.net2.png differ diff --git a/examples/MDF/RNN/iaf.png b/examples/MDF/RNN/iaf.png index e6b0ea0df..865ce7469 100644 Binary files a/examples/MDF/RNN/iaf.png and b/examples/MDF/RNN/iaf.png differ diff --git a/examples/MDF/RNN/rnn.png b/examples/MDF/RNN/rnn.png index 363582168..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/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/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_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/images/composite_example.png b/examples/MDF/conditions/images/composite_example.png index 5c253b1e3..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 e434cd057..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 f7fec4223..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/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/images/abc_conditions.png b/examples/MDF/images/abc_conditions.png index 1003fa49c..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 187889491..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 b35d746dd..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 c1ffcb879..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 e84b4e178..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 2295de8d4..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 0b79e9317..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 730b03a73..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 4e67de5ef..eca473dc5 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..745323273 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.4", "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..5565ac5ac 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,9 @@ }, "parameters": { "variable": { - "value": 2.0 + "value": [ + 2.0 + ] }, "V": { "value": 0 @@ -35,7 +37,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 +45,14 @@ }, "parameters": { "slope": { - "value": 2.0 + "value": [ + 2.0 + ] }, "intercept": { - "value": 2.0 + "value": [ + 2.0 + ] }, "V": { "value": 0 @@ -68,7 +74,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,16 +82,24 @@ }, "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 + ] }, "V": { "value": 0 @@ -107,7 +121,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,16 +129,24 @@ }, "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 + ] }, "V": { "value": 0 @@ -146,7 +168,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,10 +176,14 @@ }, "parameters": { "rate": { - "value": 0.05 + "value": [ + 0.05 + ] }, "time_step_size": { - "value": 0.1 + "value": [ + 0.1 + ] }, "OUTPUT": { "time_derivative": "(rate * INPUT) / time_step_size" @@ -181,45 +207,40 @@ } }, "edges": { - "Edge A_0 to B_0": { - "name": "Edge A_0 to B_0", + "Edge A to B": { + "name": "Edge A to B", "sender_port": "OUTPUT", "receiver_port": "INPUT", - "sender": "A_0", - "receiver": "B_0", - "weight": 1 + "sender": "A", + "receiver": "B" }, - "Edge A_input_0 to A_0": { - "name": "Edge A_input_0 to A_0", + "Edge A_input to A": { + "name": "Edge A_input to A", "sender_port": "OUTPUT", "receiver_port": "INPUT", - "sender": "A_input_0", - "receiver": "A_0", - "weight": 1 + "sender": "A_input", + "receiver": "A" }, - "Edge A_0 to C_0": { - "name": "Edge A_0 to C_0", + "Edge A to C": { + "name": "Edge A to C", "sender_port": "OUTPUT", "receiver_port": "INPUT", - "sender": "A_0", - "receiver": "C_0", - "weight": 1 + "sender": "A", + "receiver": "C" }, - "Edge B_0 to D_0": { - "name": "Edge B_0 to D_0", + "Edge B to D": { + "name": "Edge B to D", "sender_port": "OUTPUT", "receiver_port": "INPUT", - "sender": "B_0", - "receiver": "D_0", - "weight": 1 + "sender": "B", + "receiver": "D" }, - "Edge C_0 to D_0": { - "name": "Edge C_0 to D_0", + "Edge C to D": { + "name": "Edge C to D", "sender_port": "OUTPUT", "receiver_port": "INPUT", - "sender": "C_0", - "receiver": "D_0", - "weight": 1 + "sender": "C", + "receiver": "D" } } } diff --git a/examples/NeuroML/ABCD.mdf.png b/examples/NeuroML/ABCD.mdf.png index 937e9853d..84b763664 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..c7a157c82 100644 --- a/examples/NeuroML/ABCD.mdf.yaml +++ b/examples/NeuroML/ABCD.mdf.yaml @@ -1,17 +1,18 @@ 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 V: value: 0 OUTPUT: @@ -29,16 +30,18 @@ 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 V: value: 0 OUTPUT: @@ -56,20 +59,24 @@ 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 V: value: 0 OUTPUT: @@ -87,20 +94,24 @@ 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 V: value: 0 OUTPUT: @@ -118,16 +129,18 @@ 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 OUTPUT: time_derivative: (rate * INPUT) / time_step_size V: @@ -146,38 +159,33 @@ ABCD: \ parameters: {'rate': '0.05', 'time_step_size': '0.1s'}\n\ \ parent: None\n" edges: - Edge A_0 to B_0: - name: Edge A_0 to B_0 + Edge A to B: + name: Edge A to B sender_port: OUTPUT 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: A + receiver: B + Edge A_input to A: + name: Edge A_input to A sender_port: OUTPUT 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: A_input + receiver: A + Edge A to C: + name: Edge A to C sender_port: OUTPUT 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: A + receiver: C + Edge B to D: + name: Edge B to D sender_port: OUTPUT 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: B + receiver: D + Edge C to D: + name: Edge C to D sender_port: OUTPUT receiver_port: INPUT - sender: C_0 - receiver: D_0 - weight: 1 + sender: C + receiver: D diff --git a/examples/NeuroML/ABCD.net.nml b/examples/NeuroML/ABCD.net.nml index 1b5b42d2c..8468f154f 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.4 Generated network: ABCD Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/ABCD.nmllite.png b/examples/NeuroML/ABCD.nmllite.png index 6b7096bf5..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 14d0e939a..1d86d21ed 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..16d809201 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.4", "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..5b003e2a8 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,94 @@ }, "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 + ] }, "V": { "default_initial_value": "initial_v", diff --git a/examples/NeuroML/FN.mdf.yaml b/examples/NeuroML/FN.mdf.yaml index 1d0a94880..9f9851976 100644 --- a/examples/NeuroML/FN.mdf.yaml +++ b/examples/NeuroML/FN.mdf.yaml @@ -1,51 +1,69 @@ 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 V: default_initial_value: initial_v time_derivative: (a_v*V*V*V + (1+threshold_exc)*b_v*V*V diff --git a/examples/NeuroML/FN.net.nml b/examples/NeuroML/FN.net.nml index cb3783785..b976a5671 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.4 Generated network: FN Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/FNmulti.png b/examples/NeuroML/FNmulti.png index 178ac75f9..5a2681465 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 1c700f93e..89225233e 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..b4a10c1ff 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 @@ -17,17 +18,15 @@ def execute(): duration = 0.7 input_node = mod_graph.get_node("Input_stim_0") - izh_node = mod_graph.get_node("izhPop_0") + 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,13 +72,13 @@ 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) @@ -85,8 +86,8 @@ def execute(): 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},\ + 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_stim_0'].evaluable_parameters['i'].curr_value}" ) t += dt diff --git a/examples/NeuroML/IzhikevichTest.gv.png b/examples/NeuroML/IzhikevichTest.gv.png index e0484c66a..1dcf2d0e4 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..33f3612b5 100644 --- a/examples/NeuroML/IzhikevichTest.mdf.json +++ b/examples/NeuroML/IzhikevichTest.mdf.json @@ -1,41 +1,61 @@ { "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 + ] }, "v": { "default_initial_value": "v0", @@ -83,13 +103,19 @@ "Input_stim_0": { "parameters": { "amplitude": { - "value": 1e-10 + "value": [ + 1e-10 + ] }, "delay": { - "value": 0.1 + "value": [ + 0.1 + ] }, "duration": { - "value": 0.5 + "value": [ + 0.5 + ] }, "i": { "conditions": { @@ -125,12 +151,12 @@ } }, "edges": { - "Edge Input_stim_0 to izhPop_0": { - "name": "Edge Input_stim_0 to izhPop_0", + "Edge Input_stim_0 to izhPop": { + "name": "Edge Input_stim_0 to izhPop", "sender_port": "i", "receiver_port": "synapses_i", "sender": "Input_stim_0", - "receiver": "izhPop_0" + "receiver": "izhPop" } } } diff --git a/examples/NeuroML/IzhikevichTest.mdf.yaml b/examples/NeuroML/IzhikevichTest.mdf.yaml index d17dcc493..46e176002 100644 --- a/examples/NeuroML/IzhikevichTest.mdf.yaml +++ b/examples/NeuroML/IzhikevichTest.mdf.yaml @@ -1,31 +1,41 @@ 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 v: default_initial_value: v0 conditions: @@ -66,11 +76,14 @@ IzhikevichTest: Input_stim_0: parameters: amplitude: - value: 1.0e-10 + value: + - 1.0e-10 delay: - value: 0.1 + value: + - 0.1 duration: - value: 0.5 + value: + - 0.5 i: conditions: condition_0: @@ -99,9 +112,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 Input_stim_0 to izhPop: + name: Edge Input_stim_0 to izhPop sender_port: i receiver_port: synapses_i sender: Input_stim_0 - receiver: izhPop_0 + receiver: izhPop diff --git a/examples/NeuroML/IzhikevichTest.net.nml b/examples/NeuroML/IzhikevichTest.net.nml index a998e8ad7..34f852e78 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.4 Generated network: IzhikevichTest Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/IzhikevichTest.nmllite.yaml b/examples/NeuroML/IzhikevichTest.nmllite.yaml index c2f0afbb0..0f756187a 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.4 notes: Example Izhikevich parameters: N: 1 diff --git a/examples/NeuroML/LEMS_SimABCD.png b/examples/NeuroML/LEMS_SimABCD.png index 3ebbd1167..0906f4863 100644 Binary files a/examples/NeuroML/LEMS_SimABCD.png and b/examples/NeuroML/LEMS_SimABCD.png differ diff --git a/examples/NeuroML/LEMS_SimFN.png b/examples/NeuroML/LEMS_SimFN.png index e6a2f6385..2b558ab55 100644 Binary files a/examples/NeuroML/LEMS_SimFN.png and b/examples/NeuroML/LEMS_SimFN.png differ diff --git a/examples/NeuroML/LEMS_SimIzhikevichTest.png b/examples/NeuroML/LEMS_SimIzhikevichTest.png index f436a54b2..51b9a82ce 100644 Binary files a/examples/NeuroML/LEMS_SimIzhikevichTest.png and b/examples/NeuroML/LEMS_SimIzhikevichTest.png differ 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..c1764defe 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.4", "network": "ABCD.json", "duration": 5000.0, "dt": 100.0, diff --git a/examples/NeuroML/SimFN.json b/examples/NeuroML/SimFN.json index 57008b4f6..a35953b60 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.4", "network": "FN.json", "duration": 100.0, "dt": 0.05, diff --git a/examples/NeuroML/SimIzhikevichTest.yaml b/examples/NeuroML/SimIzhikevichTest.yaml index 7476f51de..a5f01884e 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.4 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.png b/examples/ONNX/ab.png index 896f36543..7b76243db 100644 Binary files a/examples/ONNX/ab.png and b/examples/ONNX/ab.png differ 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/inception.png b/examples/PyTorch/inception.png index 6c22adf70..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.png b/examples/PyTorch/mlp_pure_mdf.png index e47816d36..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/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 425a0d5b7..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.png b/examples/PyTorch/simple_pytorch_to_mdf.png index 49a7cfa5b..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 a6e12acaa..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/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}"