ProjectionGraph¶
A ProjectionGraph represents one of the core structural components of an NGC system. To use a projection graph, Node(s) and Cable(s) must be embedded/integrated into in order to simulate an ancestral projection/sampling process. Note that ProjectionGraph is only useful if an NGCGraph has been created, given that a projection graph is meant to offer non-trainable functionality, particularly fast inference, to an NGC computational system.
Projection Graph¶
The ProjectionGraph
class serves as a core building block for forming a complete
NGC computational processing system (particularly with respect to external
processes such as projection/sampling).
- class ngclearn.engine.proj_graph.ProjectionGraph(name='sampler')[source]
Implements a projection graph – useful for conducting ancestral sampling of a directed generative model or ancestral projection of a clamped graph. Note that when instantiating this object, it is important to call .compile(), like so:
graph = ProjectionGraph(…)info = graph.compile()- Parameters
name – the name of this projection graph
- set_cycle(nodes)[source]
Set execution cycle for this graph
- Parameters
nodes – an ordered list of Node(s) to create an execution cycle for
- extract(node_name, node_var_name)[source]
Extract a particular signal from a particular node embedded in this graph
- Parameters
node_name – name of the node from the NGC graph to examine
node_var_name – compartment name w/in Node to extract signal from
- Returns
an extracted signal (vector/matrix) OR None if node does not exist
- getNode(node_name)[source]
Extract a particular node from this graph
- Parameters
node_name – name of the node from the NGC graph to examine
- Returns
the desired Node (object)
- project(clamped_vars=None, readout_vars=None)[source]
Project signals through the execution pathway(s) defined by this graph
- Parameters
clamped_vars – list of 2-tuples containing named Nodes that will be clamped with particular values. Note that this list takes the form: [(node1_name, node_value1), node2_name, node_value2),…]
readout_vars – list of 2-tuple strings containing named Nodes and their compartments to read signals from. Note that this list takes the form: [(node1_name, node1_compartment), node2_name, node2_compartment),…]
- Returns
- readout values - a list of 3-tuples named signals corresponding to the ones in “readout_vars”. Note that
this list takes the form: [(node1_name, node1_compartment, value), node2_name, node2_compartment, value),…]
- clear()[source]
Clears/deletes any persistent signals currently embedded w/in this graph’s Nodes