Bricks

fugu.bricks.bricks.generate_brick_tag(brick_name)

Function that generates a unique brick tag

class fugu.bricks.bricks.Brick(name='Brick')

Bases: ABC

Abstract Base Class definition of a Brick class

brick_id = 0
classmethod input_ports() dict[str, PortSpec]

Describes the ports on which this brick will take in data from other bricks. Returns a dictionary of PortSpec objects. The key is the name of the input port as known to this brick. See scaffold.py for the definition of PortSpec. A return value of {} indicate that this brick does not take inputs. Effectively, that flags this as an input brick, in the sense that all values originate from here.

classmethod output_ports() dict[str, PortSpec]

Describes the ports on which this brick will output data to other bricks. Returns a dictionary of PortSpec objects. The key is the name of the output port as known to this brick. See scaffold.py for the definition of PortSpec. A return value of {} indicates that this brick does not produce outputs. This can happen if the brick does some form of direct I/O.

classmethod show_ports()
classmethod show_port(port: PortSpec, output: bool)

Subroutine of show_ports().

generate_neuron_name(neuron_name)

Adds the brick_tag to a neuron’s name

build2(graph, inputs: dict[str, PortData] = {})

Builds the computational graph of the brick. This method uses Ports to convey its inputs and outputs.

The default implementation here acts as a shim to legacy bricks that use an older style of conveying inputs and outputs. New brick classes should override this method, and should avoid build() in any form.

Parameters:
  • graph (NetworkX.DiGraph) – The neural network being built.

  • inputs (dict) – A collection ports feeding into this brick. The dictionery represents bindings between our input ports and the outputs supplied by other bricks. The key is the name of the input port as known to this brick and described by input_ports(). The value is a PortData object created by the source brick.

Returns:

A dictionary of PortData objects. The key is the name of the port as known to this brick and described by output_ports().

build(graph, metadata, control_nodes, input_lists, input_codings)

Deprecated method for building the computational graph of the brick. New brick subclasses should override build2() instead.

Parameters:
  • graph (graph) – networkx graph

  • metadata (dictionary) – A dictionary of shapes and properties

  • control_nodes (list) –

    list of dictionary of auxillary nodes. Acceptable keys include:

    ’complete’ - A list of neurons that fire when the brick is done ‘begin’ - A list of neurons that fire when the brick begins computation

    (used for temporal processing)

  • input_lists (list) – list of lists of nodes for input neurons

  • input_codings (list) – list of input coding types (as strings)

set_properties(graph, properties)

Returns an updated version of the graph based on the property values passed.

class fugu.bricks.bricks.InputBrick(name='InputBrick')

Bases: Brick

Abstract Base class for handling inputs inherited from Brick

abstract get_input_value(t=None)

Abstract method to get input values. InputBricks must implement this method

Parameters:

t – type of input (Default: None)

set_properties(properties=None)

Returns an updated version of the graph based on the property values passed.

class fugu.bricks.bricks.CompoundBrick(name='CompoundBrick')

Bases: Brick

Abstract Base Class definition of a CompoundBrick class. A CompoundBrick is brick that contains other bricks.

brick_id = 0
build_child(brick, graph, metadata, control_nodes, input_lists, input_codings)
abstract build(graph, metadata, control_nodes, input_lists, input_codings)

Build the computational graph of the brick. Method must be defined in any class inheriting from Brick.

Parameters:
  • graph – networkx graph

  • metadata – A dictionary of shapes and properties

  • control_nodes (list) –

    list of dictionary of auxillary nodes. Acceptable keys include:

    ’complete’ - A list of neurons that fire when the brick is done ‘begin’ - A list of neurons that fire when the brick begins computation

    (used for temporal processing)

  • input_lists (list) – list of lists of nodes for input neurons

  • input_codings (list) – list of input coding types (as strings)

set_properties(graph, properties)

Returns an updated version of the graph based on the property values passed.

class fugu.bricks.bricks.generate_brick_tag(brick_name)

Bases:

Function that generates a unique brick tag