globs – Globs, or syntactic sugar.

Platforms: Any

Glob - class for Globs.

class nodes.globs.Glob([nodes[, shape[, inputs, outputs]]][, name=''])

Class for Globs. It provides all necessary Globs interface. Constructor arguments: :param nodes: List of Node’s specifications. Nodes’ specifications are tuples (name, class). Name is unique string, class is subclass of core.Node. Class constructor will be called with usual Node arguments, considered with class core.Node.__shape__. :type nodes: list of tuples(string, classobj)

Parameters:
  • shape (list of tuples/lists (string, string[, integer, integer[, float, float]])) – List of edges (arcs) specifications. Actually, edge specification is tuple of arguments for connect(), but first two items are strings (names), not Node instances.
  • inputs, outputs (lists of strings.) – Lists of names of Nodes which supports Input Interface and Output Interface. Currently, Glob can’t guess it with introspection.
  • name (string.) – Name of Glob. It may be non-unique.

Methods

make_shape(nodes, edges)
Internal method to make Glob’s shape. Arguments meanings are same that in constructor. :param nodes, shapes: see Glob constructor.
add(name, nodclass, input_edges, output_edges)
addInput(...)
addoutput(...)
Add new Node into a Glob. name and nodclass means the same that Node’s specification. input_edges and output_edges are lists of edge specification, but with ommited item (second in input_edges, first in output_edges). addInput and addOutput both do same stuff, but also adds Node to inputs/outputs list. :param name: name of new Node. :type name: string. :param nodclass: class of new Node. :type nodclass: core.Node subclass. :param input_edges, output_edges: edges to connect inputs/outputs with. :type input_edges, output_edges: lists of tuples/lists.

Note

There are no currentlymethod(s) to delete Nodes because there are many ambiguous moments. Yes, destruction is more complex than construction!

calculate([values][, doubly=True])
Calculates a net and return list of results. values are input values; if doubly is True, makes invoked random input and output Node; otherwise, only output Node. It uses “blocking” core.Node.touch() method. :param values: input values. :type values: list/array of numerical values. :param doubly: flag shows if double-invocation is necessary :type doubly: bool. :returns: output values. :rtype: list of numerical values.
compute([values[, doubly=False]])
Computes a net and return list of results. Meanings of arguments are same that in calculate(). It computes a net using “layer calculation” core.Node.compute() method, so it does several runs until results will become stable. It is good for simple or complex net topology.
print_self()
Debug method that prints all values and weights in net.

Instance attributes

sysname
Name of Glob.
nodes
Dictionary with Nodes names as keys and core.Node instances as values.
inputs
outputs
Lists of Nodes that are input/output in net.
Variable syname:
 name of Glob.
Variable nodes:names-to-Nodes mapping.
Variable inputs, outputs:
 lists of input/output Nodes.
nodes.globs.connect(innode, outnode[, inindex, outindex[, inweight, outweight]])
Connects two Nodes. Meanings of fist four arguments are same that in core.Synaps.bind(). :param innode, outnode: Nodes to connect. :type innode, outnode: core.Node instances. :param inindex, outindex: indices to which new arc bind. :type inindex, outindex: integers. :param inweight, outweight: weights of arc. inweight is actually output weight of innode, and outweight is input weight for outnode.

Input Interface

Following the principles of duck typing, input interface means that Node has a put(value) method, where value is number.

Output Interface

Output interface means that Node has a get() method which
returns numerical value.