Comments (6)
The one concern I have with removing lists is that we don't currently have a way of specifying the order of functions (and to a lesser degree, ports, but I think that may just be a psyneulink-specific issue and one we can work around fairly easily with some pnl-specific parameters). In this example, it's not clear how linear_1
and logistic_1
interact. With lists, [{linear_1 ...}, {logistic_1 ..}]
gives an explicit ordering. It could be as simple as a comma-separated string of function names, somewhere, but it's not clear to me where a good place for this is. I think the alternative of enforcing one node = one function would be problematic for psyneulink as well.
from mdf.
@kmantel There are 2 separate issues here, as obviously the json/yaml serialisation has an existing ordering for list or dict entries when written to a text file.
- Does the new dict format allow preservation of the order when loaded in to Python? In this case it does, through the use of Ordered dicts, so:
for f in functions
(or nodes, parameters, etc.) will return the function (keys) in the same order as the file, and the elements will be serialised in the same order again if not changed. - Does the order of the functions define the order in which they have to be evaluated? In this case I'd say no. We should give the user the freedom to write them in any way, as long as they're consistent, and the reading application should solve the order. So (assuming a is another parameter) 'x = sin(y); y=sin(a)' and 'y=sin(a); x = sin(y)' should both be allowed, and the parser sorts them to the correct evaluation order (or used symbolic manipulation to optimise).
from mdf.
@pgleeson I think the native python handler for JSON can be specified to respect ordering in a JSON file, but the JSON spec states the key/value pairs are unordered. For YAML, the spec also says key/value pairs are unordered. Additionally, the closest-to-native python implementation (pyyaml) does not respect ordering, though it seems like some others have written parsers that do respect it. I think it would be better to be explicit and not rely on non-spec orders for cases it's not clear.
- This is a fair point. I suppose if the spec is defined as having a clear ordering detectable from the variables inside each function, it works. Additionally, it seems to require the function to always be explicitly written out rather than just listed, if part of any predefined bank of functions. That is, two linear functions would have to be written as something like
{
"linear_1": {
"type": "linear",
"slope": 1
},
"linear_2": {
"type": "linear",
"slope": 2
},
"primary": {
"<?>": "y = linear_1(linear_2(x))"
}
}
or just in full symbolic form. After considering this, if we are assuming that every environment can handle generic function parsing, it seems that there shouldn't be a problem with a lack of ordering.
from mdf.
Re your point on 1, yes, that's true, we can't rely that any given parser will read in the dicts in the correct order. My priority with getting the existing api to do it was mainly to help preserve readability of the json (as long as the elements were added in a sensible order) and make sure what gets read in is written identically.
In agreement with your point on 2, that the correct order should be determinable from the expressions themselves, this should be true in general, i.e. if nodes A->B, we shouldn't throw an error if B is defined before A, the order of execution should be determined by the edges. As and where lists are really required we can use them, but I don't believe they are in this case.
Another reason for avoiding lists if possible is that it makes the accessing/parsing of elements fo the graph more uniform (in Python and other potential languages), e.g. graphs['simple'].nodes['input_nodes'] and graphs['simple'].nodes['processing_nodes'].functions['linear_1'] as opposed to iterating over the list and matching ids.
from mdf.
Will be closed by #59
from mdf.
This is standard now in the code.
from mdf.
Related Issues (20)
- Error on DDM model for pytorch HOT 1
- Remove sphinx pin to 3.x? HOT 1
- torch.fx to MDF
- Support for populations/templates HOT 1
- Support for cyclical graphs HOT 3
- onnx 1.14 incompatibility HOT 2
- Py3.10 builds failing due to fastkde HOT 1
- simple_pytorch_to_mdf.py breaking in pytorch 2.0 HOT 2
- Example for testing with Keras->MDF conversion: 3D convolutional neural network HOT 1
- Refactor PyTorch_MDF examples to ease benchmarking HOT 2
- Keras to MDF HOT 1
- Support PyTorch v2.2.0
- Support latest graph_scheduler HOT 5
- ACTR importer condition typo? HOT 1
- Tasks/ Milestones HOT 1
- Missing Link to Functions List in Parameter Section in Documentation HOT 4
- Incorrect GitHub Edit Links in 'modeci_mdf' API Reference Section
- Failure of tests on macos-latest on graphviz setup step
- Allow parameters in Graph to be accessible from any node?
- pypi refusing to make new release as modeci requires verified email HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mdf.