Skip to content

Commit 6201123

Browse files
authored
Merge pull request #548 from ModECI/cyclic_graphs
Cyclical graphs support
2 parents 592174a + 1e851d6 commit 6201123

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+883
-55
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ Thumbs.db #thumbnail cache on Windows
274274
/examples/PyTorch/simple_pytorch_to_mdf.1
275275
/examples/MDF/NLP/TestNLP_3
276276
/examples/MDF/NLP/TestNLP
277+
/examples/MDF/networks/Net_acyclical
278+
/examples/MDF/net/Net_acyclical
279+
/examples/MDF/net/weight.py
277280
/examples/MDF/conditions/composite_example
278281
/examples/NeuroML/arm64
279282
/examples/MDF/RNN/iaf.net

docs/MDF_specification.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,21 @@
106106
"type": "str",
107107
"description": "The unique (for this Node) id of the input port,"
108108
},
109+
"default_value": {
110+
"type": "Union[EvaluableExpression, List, Dict, ndarray, int, float, str, NoneType]",
111+
"description": "Value to set at this input port if no edge connected to it."
112+
},
109113
"shape": {
110114
"type": "Union[Tuple[int, ...], NoneType]",
111115
"description": "The shape of the input port. This uses the same syntax as numpy ndarray shapes\n(e.g., :code:`numpy.zeros(shape)` would produce an array with the correct shape"
112116
},
113117
"type": {
114118
"type": "Union[str, NoneType]",
115119
"description": "The data type of the input received at a port."
120+
},
121+
"reduce": {
122+
"type": "Union[str, NoneType]",
123+
"description": "Specifies how to deal with multiple inputs to one port during a single timestep: add: add up all the values; multiply: multiply the values, overwrite: just use the last value supplied (default)"
116124
}
117125
}
118126
},

docs/MDF_specification.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ specification:
9191
id:
9292
type: str
9393
description: The unique (for this Node) id of the input port,
94+
default_value:
95+
type: Union[EvaluableExpression, List, Dict, ndarray, int, float,
96+
str, NoneType]
97+
description: Value to set at this input port if no edge connected
98+
to it.
9499
shape:
95100
type: Union[Tuple[int, ...], NoneType]
96101
description: 'The shape of the input port. This uses the same syntax
@@ -101,6 +106,12 @@ specification:
101106
type:
102107
type: Union[str, NoneType]
103108
description: The data type of the input received at a port.
109+
reduce:
110+
type: Union[str, NoneType]
111+
description: 'Specifies how to deal with multiple inputs to one port
112+
during a single timestep: add: add up all the values; multiply:
113+
multiply the values, overwrite: just use the last value supplied
114+
(default)'
104115
Function:
105116
definition: A single value which is evaluated as a function of values on :class:`InputPort`(s)
106117
and other Functions

docs/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ The <a href="#inputport">InputPort</a> is an attribute of a Node which allows ex
179179
</tr>
180180

181181

182+
<tr>
183+
<td><b>default_value</b></td>
184+
<td>Union[EvaluableExpression, List, Dict, ndarray, int, float, str, NoneType]</td>
185+
<td><i>Value to set at this input port if no edge connected to it.</i></td>
186+
</tr>
187+
188+
182189
<tr>
183190
<td><b>shape</b></td>
184191
<td>Union[Tuple[int, ...], NoneType]</td>
@@ -194,6 +201,13 @@ The <a href="#inputport">InputPort</a> is an attribute of a Node which allows ex
194201
</tr>
195202

196203

204+
<tr>
205+
<td><b>reduce</b></td>
206+
<td>Union[str, NoneType]</td>
207+
<td><i>Specifies how to deal with multiple inputs to one port during a single timestep: add: add up all the values; multiply: multiply the values, overwrite: just use the last value supplied (default)</i></td>
208+
</tr>
209+
210+
197211
</table>
198212

199213
## Function

docs/sphinx/source/api/Specification.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,17 @@ The `InputPort <#inputport>`__ is an attribute of a Node which allows external i
8787

8888
**Allowed parameters**
8989

90-
=============== ================================ =============================================================================================
91-
Allowed field Data Type Description
92-
=============== ================================ =============================================================================================
93-
**metadata** Union[Any, NoneType] Optional metadata field, an arbitrary dictionary of string keys and JSON serializable values.
94-
**id** str The unique (for this Node) id of the input port,
95-
**shape** Union[Tuple[int, ...], NoneType] The shape of the input port. This uses the same syntax as numpy ndarray shapes
96-
(e.g., **numpy.zeros(shape)** would produce an array with the correct shape
97-
**type** Union[str, NoneType] The data type of the input received at a port.
98-
=============== ================================ =============================================================================================
90+
================= ========================================================================== =================================================================================================================================================================================================
91+
Allowed field Data Type Description
92+
================= ========================================================================== =================================================================================================================================================================================================
93+
**metadata** Union[Any, NoneType] Optional metadata field, an arbitrary dictionary of string keys and JSON serializable values.
94+
**id** str The unique (for this Node) id of the input port,
95+
**default_value** Union[EvaluableExpression, List, Dict, ndarray, int, float, str, NoneType] Value to set at this input port if no edge connected to it.
96+
**shape** Union[Tuple[int, ...], NoneType] The shape of the input port. This uses the same syntax as numpy ndarray shapes
97+
(e.g., **numpy.zeros(shape)** would produce an array with the correct shape
98+
**type** Union[str, NoneType] The data type of the input received at a port.
99+
**reduce** Union[str, NoneType] Specifies how to deal with multiple inputs to one port during a single timestep: add: add up all the values; multiply: multiply the values, overwrite: just use the last value supplied (default)
100+
================= ========================================================================== =================================================================================================================================================================================================
99101

100102
========
101103
Function
Loading
Loading
149 Bytes
Loading

examples/MDF/RNN/IAF_net.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"current_input": {
5757
"shape": [
5858
8
59-
]
59+
],
60+
"reduce": "add"
6061
}
6162
},
6263
"parameters": {
@@ -140,7 +141,8 @@
140141
"current_input": {
141142
"shape": [
142143
8
143-
]
144+
],
145+
"reduce": "add"
144146
}
145147
},
146148
"parameters": {
@@ -224,7 +226,8 @@
224226
"spike_input": {
225227
"shape": [
226228
8
227-
]
229+
],
230+
"reduce": "add"
228231
}
229232
},
230233
"parameters": {

examples/MDF/RNN/IAF_net.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ IAF_net:
4040
current_input:
4141
shape:
4242
- 8
43+
reduce: add
4344
parameters:
4445
v0:
4546
value:
@@ -99,6 +100,7 @@ IAF_net:
99100
current_input:
100101
shape:
101102
- 8
103+
reduce: add
102104
parameters:
103105
v0:
104106
value:
@@ -158,6 +160,7 @@ IAF_net:
158160
spike_input:
159161
shape:
160162
- 8
163+
reduce: add
161164
parameters:
162165
syn_tau:
163166
value: 10

examples/MDF/RNN/IAF_net2.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"current_input": {
6666
"shape": [
6767
8
68-
]
68+
],
69+
"reduce": "add"
6970
}
7071
},
7172
"parameters": {
@@ -149,7 +150,8 @@
149150
"current_input": {
150151
"shape": [
151152
8
152-
]
153+
],
154+
"reduce": "add"
153155
}
154156
},
155157
"parameters": {
@@ -233,7 +235,8 @@
233235
"spike_input": {
234236
"shape": [
235237
8
236-
]
238+
],
239+
"reduce": "add"
237240
}
238241
},
239242
"parameters": {

examples/MDF/RNN/IAF_net2.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ IAF_net2:
4848
current_input:
4949
shape:
5050
- 8
51+
reduce: add
5152
parameters:
5253
v0:
5354
value:
@@ -107,6 +108,7 @@ IAF_net2:
107108
current_input:
108109
shape:
109110
- 8
111+
reduce: add
110112
parameters:
111113
v0:
112114
value:
@@ -166,6 +168,7 @@ IAF_net2:
166168
spike_input:
167169
shape:
168170
- 8
171+
reduce: add
169172
parameters:
170173
syn_tau:
171174
value: 10

0 commit comments

Comments
 (0)