neuromancer.system module
open-loop (directed acyclic graphs) and closed-loop (directed cyclic graphs) systems components
Minimum viable product 1, system class for open-loop rollout of autonomous nn.Module class 2, system class for open-loop rollout of non-autonomous nn.Module class 3, system class for closed-loop rollout of simple DPC with neural policy and nonautonomous dynamics class (e.g. SSM, psl, …)
Notes on simple implementation:
Time delay can be handled inside nodes simply or with more complexity Sporadically sampled data can be handled prior with interpolation Different time scales can be handled with nested systems Networked systems seem like a natural fit here
- class neuromancer.system.MovingHorizon(module, ndelay=1, history=None)[source]
Bases:
Module
The MovingHorizon class buffers single time step inputs for time-delay modeling from past ndelay steps. This class is a wrapper which does data handling for modules which take 3-d input (batch, time, dim)
- forward(input)[source]
The forward pass appends the input dictionary to the history buffer and gives last ndelay steps to the module. If history is blank the first step will be repeated ndelay times to initialize the buffer.
- Parameters:
input – (dict: str: 2-d tensor (batch, dim)) Dictionary of single step tensor inputs
- Returns:
(dict: str: 3-d Tensor (ndelay, batch, dim)) Dictionary of tensor outputs
- class neuromancer.system.Node(callable, input_keys, output_keys, name=None)[source]
Bases:
Module
Simple class to handle cyclic computational graph connections. input_keys and output_keys define computational node connections through intermediate dictionaries.
- class neuromancer.system.System(nodes, name=None, nstep_key='X', init_func=None, nsteps=None)[source]
Bases:
Module
Simple implementation for arbitrary cyclic computation
- cat(data3d, data2d)[source]
Concatenates data2d contents to corresponding entries in data3d :param data3d: (dict {str: Tensor}) Input to a node :param data2d: (dict {str: Tensor}) Output of a node :return: (dict: {str: Tensor})
- forward(input_dict)[source]
- Parameters:
input_dict – (dict: {str: Tensor}) Tensor shapes in dictionary are asssumed to be (batch, time, dim) If an init function should be written to assure that any 2-d or 1-d tensors have 3 dims.
- Returns:
(dict: {str: Tensor}) data with outputs of nstep rollout of Node interactions
- init(data)[source]
- Parameters:
data – (dict: {str: Tensor}) Tensor shapes in dictionary are asssumed to be (batch, time, dim)
- Returns:
(dict: {str: Tensor})
Any nodes in the graph that are start nodes will need some data initialized. Here is an example of initializing an x0 entry in the input_dict.
Provide in base class analysis of computational graph. Label the source nodes. Keys for source nodes have to be in the data.