Utility Bricks

class fugu.bricks.utility_bricks.Dot(weights, name='Dot')

Bases: Brick

Class to handle the Dot brick. Inherits from Brick

Construtor for this brick. :param weights: Vector against which the input is dotted. :type weights: any :param name: Name of the brick. If not specified, a default will be used. Name should be unique. :type name: str

set_properties(properties)

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

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

Build Dot brick.

Parameters:
  • graph (any) – networkx graph to define connections of the computational graph

  • metadata (dict) – dictionary to define the shapes and parameters of the brick

  • control_nodes (list) –

    list of dictionary of auxillary nodes. Expected keys:

    ’complete’ - A list of neurons that fire when the brick is done

  • input_lists (list) – list of nodes that will contain input

  • input_coding (list) – list of input coding formats. (‘Raster’, ‘Undefined’ supported)

Returns:

graph of a computational elements and connections metadata: dictionary of output parameters (shape, coding, layers, depth, etc) complete_name: list dictionary of control nodes (‘complete’) output_list (list[dict[str, int]]): list of output edges output_codings (list[str]): list of coding formats of output (‘current’)

Return type:

graph

class fugu.bricks.utility_bricks.Copy(name='Copy')

Bases: Brick

Class to handle Copy Brick. Inherits from Brick

Construtor for this brick. :param name: Name of the brick. If not specified, a default will be used. Name should be unique. :type name: str

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

Build Copy brick.

Parameters:
  • graph – networkx graph to define connections of the computational graph

  • metadata (dict) – dictionary to define the shapes and parameters of the brick

  • control_nodes (list) –

    list of dictionaries of auxillary nodes. Expected keys:

    ’complete’ - A list of neurons that fire when the brick is done

  • input_lists (list) – list of nodes that will contain input

  • input_coding (list) – list of input coding formats

Returns:

graph of a computational elements and connections self.metadata (dict): dictionary of output parameters (shape, coding, layers, depth, etc) complete: list dictionary of control nodes (‘complete’) output_lists (list[list]): list of output output_codings (list): list of coding formats of output

Return type:

graph

class fugu.bricks.utility_bricks.Concatenate(name='Concatenate', coding=None)

Bases: Brick

Brick that concatenates multiple inputs into a single vector. All codings are supported except ‘current’; first coding is used if not specified.

Parameters:

name (str) – Name of the brick. If not specified, a default will be used. Name should be unique.

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

Build concatenate brick.

Parameters:
  • graph – networkx graph to define connections of the computational graph

  • metadata (dict) – dictionary to define the shapes and parameters of the brick

  • control_nodes (list) –

    dictionary of lists of auxillary networkx nodes. Expected keys:

    ’complete’ - A list of neurons that fire when the brick is done

  • input_lists (list) – list of nodes that will contain input

  • input_coding (list) – list of input coding formats. All codings are allowed except ‘current’.

Returns:

graph of a computational elements and connections self.metadata (dict[str, int]): dictionary (dict[str, int]) of output parameters (shape, coding, layers, depth, etc) dictionary of control nodes (‘complete’) output_list: list of lists of output (1 output) output_codings (list): list of coding formats of output (Coding matches input coding)

class fugu.bricks.utility_bricks.AND_OR(mode='AND', name='AND_OR')

Bases: Brick

Brick for performing a logical AND/OR. Operation is performed entry-wise, matching based on index. All codings are supported.

Parameters:
  • mode (str) – Either ‘And’ or ‘Or’; determines the operation

  • name (str) – Name of the brick. If not specified, a default will be used. Name should be unique.

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.

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

Build AND_OR brick. :raises ValueError: If != 2 inputs. Only 2 inputs are supported. Error if unsupported mode.

class fugu.bricks.utility_bricks.ParityCheck(name='ParityCheck')

Bases: Brick

Brick to compute the parity of a 4 bit input. The output spikes after 2 time steps if the input has odd parity

Construtor for this brick. :param name: Name of the brick. If not specified, a default will be used. Name should be unique. :type name: str

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

Build Parity brick.

Parameters:
  • graph – networkx graph to define connections of the computational graph

  • metadata (dict) – dictionary to define the shapes and parameters of the brick

  • control_nodes (list) – dictionary of lists of auxillary networkx nodes. Expected keys: ‘complete’ - A list of neurons that fire when the brick is done

  • input_lists (list) – list of nodes that will contain input

  • input_coding (list) – list of input coding formats

Returns:

graph of a computational elements and connections self.metadata (dict): dictionary of output parameters (shape, coding, layers, depth, etc). dict[str, int] = {‘D’: 1} complete_node (str): dictionary of control nodes (‘complete’) output_lists (list[list[str]]): list of output output_codings (list): list of coding formats of output

Return type:

graph

Example

add 4 hidden nodes with thresholds <=1, >=1, <=3, >=3. since the thresholds only compute >=, the <=1, <=3 computations are performed by negating the threshold weights and the inputs (via the weights on incomming edges) first hidden node and connect edges from input layer

class fugu.bricks.utility_bricks.TemporalAdder(number_of_elements, design='default', name='TemporalAdder', output_coding='temporal-L')

Bases: Brick

Brick that “adds” spike times together:

More specifically, consider you have three neurons u, v, and w that first spike at times t_u, t_v, and t_w. Assuming v spikes before w (so t_v < t_w), we want t_u = t_w + t_v, i.e. u fires t_v timesteps after w fires.

Construtor for this brick. :param number_of_elements: number of signals you want to add together :type number_of_elements: any :param design: default :type design: str :param name: Name of the brick. If not specified, a default will be used. Name should be unique. :type name: str :param output_coding: Output coding type, default is ‘temporal-L’ :type output_coding: str

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

Build Adder brick.

Parameters:
  • graph – networkx graph to define connections of the computational graph

  • metadata – dictionary to define the shapes and parameters of the brick

  • control_nodes

    dictionary of lists of auxillary networkx nodes. Expected keys:

    ’complete’ - A list of neurons that fire when the brick is done ‘begin’ - A neurons that first when the brick begins processing (for temporal coded inputs)

  • input_lists – list of nodes that will contain input

  • input_coding – list of input coding formats. All coding types supported

Returns:

graph of a computational elements and connections self.metadata: dictionary of output parameters (shape, coding, layers, depth, etc) complete_node_list: dictionary of control nodes (‘complete’) output_lists: list of output self.output_coings: list of coding formats of output

Return type:

graph

Raises:

ValueError – incorrect number or format of inputs

class fugu.bricks.utility_bricks.Dot(weights, name='Dot')

Bases: Brick

Class to handle the Dot brick. Inherits from Brick

Construtor for this brick. :param weights: Vector against which the input is dotted. :type weights: any :param name: Name of the brick. If not specified, a default will be used. Name should be unique. :type name: str

set_properties(properties)

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

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

Build Dot brick.

Parameters:
  • graph (any) – networkx graph to define connections of the computational graph

  • metadata (dict) – dictionary to define the shapes and parameters of the brick

  • control_nodes (list) –

    list of dictionary of auxillary nodes. Expected keys:

    ’complete’ - A list of neurons that fire when the brick is done

  • input_lists (list) – list of nodes that will contain input

  • input_coding (list) – list of input coding formats. (‘Raster’, ‘Undefined’ supported)

Returns:

graph of a computational elements and connections metadata: dictionary of output parameters (shape, coding, layers, depth, etc) complete_name: list dictionary of control nodes (‘complete’) output_list (list[dict[str, int]]): list of output edges output_codings (list[str]): list of coding formats of output (‘current’)

Return type:

graph

class fugu.bricks.utility_bricks.Concatenate(name='Concatenate', coding=None)

Bases: Brick

Brick that concatenates multiple inputs into a single vector. All codings are supported except ‘current’; first coding is used if not specified.

Parameters:

name (str) – Name of the brick. If not specified, a default will be used. Name should be unique.

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

Build concatenate brick.

Parameters:
  • graph – networkx graph to define connections of the computational graph

  • metadata (dict) – dictionary to define the shapes and parameters of the brick

  • control_nodes (list) –

    dictionary of lists of auxillary networkx nodes. Expected keys:

    ’complete’ - A list of neurons that fire when the brick is done

  • input_lists (list) – list of nodes that will contain input

  • input_coding (list) – list of input coding formats. All codings are allowed except ‘current’.

Returns:

graph of a computational elements and connections self.metadata (dict[str, int]): dictionary (dict[str, int]) of output parameters (shape, coding, layers, depth, etc) dictionary of control nodes (‘complete’) output_list: list of lists of output (1 output) output_codings (list): list of coding formats of output (Coding matches input coding)

class fugu.bricks.utility_bricks.AND_OR(mode='AND', name='AND_OR')

Bases: Brick

Brick for performing a logical AND/OR. Operation is performed entry-wise, matching based on index. All codings are supported.

Parameters:
  • mode (str) – Either ‘And’ or ‘Or’; determines the operation

  • name (str) – Name of the brick. If not specified, a default will be used. Name should be unique.

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.

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

Build AND_OR brick. :raises ValueError: If != 2 inputs. Only 2 inputs are supported. Error if unsupported mode.

class fugu.bricks.utility_bricks.ParityCheck(name='ParityCheck')

Bases: Brick

Brick to compute the parity of a 4 bit input. The output spikes after 2 time steps if the input has odd parity

Construtor for this brick. :param name: Name of the brick. If not specified, a default will be used. Name should be unique. :type name: str

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

Build Parity brick.

Parameters:
  • graph – networkx graph to define connections of the computational graph

  • metadata (dict) – dictionary to define the shapes and parameters of the brick

  • control_nodes (list) – dictionary of lists of auxillary networkx nodes. Expected keys: ‘complete’ - A list of neurons that fire when the brick is done

  • input_lists (list) – list of nodes that will contain input

  • input_coding (list) – list of input coding formats

Returns:

graph of a computational elements and connections self.metadata (dict): dictionary of output parameters (shape, coding, layers, depth, etc). dict[str, int] = {‘D’: 1} complete_node (str): dictionary of control nodes (‘complete’) output_lists (list[list[str]]): list of output output_codings (list): list of coding formats of output

Return type:

graph

Example

add 4 hidden nodes with thresholds <=1, >=1, <=3, >=3. since the thresholds only compute >=, the <=1, <=3 computations are performed by negating the threshold weights and the inputs (via the weights on incomming edges) first hidden node and connect edges from input layer

class fugu.bricks.utility_bricks.TemporalAdder(number_of_elements, design='default', name='TemporalAdder', output_coding='temporal-L')

Bases: Brick

Brick that “adds” spike times together:

More specifically, consider you have three neurons u, v, and w that first spike at times t_u, t_v, and t_w. Assuming v spikes before w (so t_v < t_w), we want t_u = t_w + t_v, i.e. u fires t_v timesteps after w fires.

Construtor for this brick. :param number_of_elements: number of signals you want to add together :type number_of_elements: any :param design: default :type design: str :param name: Name of the brick. If not specified, a default will be used. Name should be unique. :type name: str :param output_coding: Output coding type, default is ‘temporal-L’ :type output_coding: str

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

Build Adder brick.

Parameters:
  • graph – networkx graph to define connections of the computational graph

  • metadata – dictionary to define the shapes and parameters of the brick

  • control_nodes

    dictionary of lists of auxillary networkx nodes. Expected keys:

    ’complete’ - A list of neurons that fire when the brick is done ‘begin’ - A neurons that first when the brick begins processing (for temporal coded inputs)

  • input_lists – list of nodes that will contain input

  • input_coding – list of input coding formats. All coding types supported

Returns:

graph of a computational elements and connections self.metadata: dictionary of output parameters (shape, coding, layers, depth, etc) complete_node_list: dictionary of control nodes (‘complete’) output_lists: list of output self.output_coings: list of coding formats of output

Return type:

graph

Raises:

ValueError – incorrect number or format of inputs