ml_genn.connectivity package

Connectivity objects are used to describe different sorts of connectivity which can be used by ml_genn.Connection objects

class ml_genn.connectivity.AvgPool2D(pool_size, flatten=False, pool_strides=None, delay=0)

Bases: Connectivity

Average pooling connectivity from source populations with 2D shape

Parameters:
  • pool_size (Param2D) – Factors by which to downscale. If only one integer is specified, the same factor will be used for both dimensions.

  • flatten (bool) – Should shape of output be flattened?

  • pool_strides (Optional[Param2D]) – Strides values. These will default to pool_size. If only one integer is specified, the same stride will be used for both dimensions.

  • delay (InitValue) – Homogeneous connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.AvgPoolConv2D(weight, filters, pool_size, conv_size, flatten=False, pool_strides=None, conv_strides=None, conv_padding='valid', delay=0)

Bases: Connectivity

Average pooling connectivity from source populations with 2D shape, fused with convolution. These are typically used when converting ANNs where there is no non-linearity between Average Pooling and Convolutional layers.

Parameters:
  • weight (InitValue) – Convolution kernel weights. Must be either a constant value, a ml_genn.initializers.Initializer or a numpy array whose shape matches conv_size and filters.

  • filters (int) – The number of filters in the convolution

  • pool_size (Param2D) – Factors by which to downscale. If only one integer is specified, the same factor will be used for both dimensions.

  • conv_size (Param2D) – The size of the convolution window. If only one integer is specified, the same factor will be used for both dimensions.

  • flatten (bool) – Should shape of output be flattened?

  • pool_strides (Optional[Param2D]) – Strides values for the pooling. These will default to pool_size. If only one integer is specified, the same stride will be used for both dimensions.

  • conv_strides (Optional[Param2D]) – Strides values for the convoltion. These will default to (1, 1). If only one integer is specified, the same stride will be used for both dimensions.

  • conv_padding (str) – either “valid” or “same”. “valid” means no padding. “same” results in padding evenly to the left/right or up/down of the input. When padding=”same” and strides=1, the output has the same size as the input.

  • delay (InitValue) – Homogeneous connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.AvgPoolDense2D(weight, pool_size, pool_strides=None, delay=0)

Bases: Connectivity

Average pooling connectivity from source populations with 2D shape, fused with dense layer. These are typically used when converting ANNs where there is no non-linearity between Average Pooling and dense layers.

Parameters:
  • weight (InitValue) – Connection weights

  • pool_size – Factors by which to downscale. If only one integer is specified, the same factor will be used for both dimensions.

  • pool_strides – Strides values for the pooling. These will default to pool_size. If only one integer is specified, the same stride will be used for both dimensions.

  • delay (InitValue) – Homogeneous connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.Connectivity(weight, delay)

Bases: ABC

Base class for all connectivity classes.

Parameters:
  • weight (InitValue) – Connection weights

  • delay (InitValue) – Connection delays

abstract connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
abstract get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.Conv2D(weight, filters, conv_size, flatten=False, conv_strides=None, conv_padding='valid', delay=0)

Bases: Connectivity

Convolutional connectivity from source populations with 2D shape.

Parameters:
  • weight (InitValue) – Convolution kernel weights. Must be either a constant value, a ml_genn.initializers.Initializer or a numpy array whose shape matches conv_size and filters.

  • filters (int) – The number of filters in the convolution

  • conv_size (Param2D) – The size of the convolution window. If only one integer is specified, the same factor will be used for both dimensions.

  • flatten (bool) – Should shape of output be flattened?

  • conv_strides (Optional[Param2D]) – Strides values for the convoltion. These will default to (1, 1). If only one integer is specified, the same stride will be used for both dimensions.

  • conv_padding (str) – either “valid” or “same”. “valid” means no padding. “same” results in padding evenly to the left/right or up/down of the input. When padding=”same” and strides=1, the output has the same size as the input.

  • delay (InitValue) – Homogeneous connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.Conv2DTranspose(weight, filters, conv_size, flatten=False, conv_strides=None, conv_padding='valid', delay=0)

Bases: Connectivity

Transposed convolutional connectivity from source populations with 2D shape.

Parameters:
  • weight (InitValue) – Convolution kernel weights. Must be either a constant value, a ml_genn.initializers.Initializer or a numpy array whose shape matches conv_size and filters.

  • filters (int) – The number of filters in the convolution

  • conv_size (Param2D) – The size of the convolution window. If only one integer is specified, the same factor will be used for both dimensions.

  • flatten – Should shape of output be flattened?

  • conv_strides (Optional[Param2D]) – Strides values for the convoltion. These will default to (1, 1). If only one integer is specified, the same stride will be used for both dimensions.

  • conv_padding (str) – either “valid” or “same”. “valid” means no padding. “same” results in padding evenly to the left/right or up/down of the input. When padding=”same” and strides=1, the output has the same size as the input.

  • delay (InitValue) – Homogeneous connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.Dense(weight, delay=0)

Bases: Connectivity

Dense connectivity.

Parameters:
  • weight (InitValue) – Connection weights. Must be either a constant value, a ml_genn.initializers.Initializer or a numpy array whose shape is (source_size, target_size).

  • delay (InitValue) – Connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.FixedProbability(p, weight, allow_self_connections=False, delay=0)

Bases: SparseBase

Sparse connectivity where there is a fixed probability of any pair of source and target neurons being connected.

Parameters:
  • p (float) – Probability of connection

  • weight (InitValue) – Connection weights. Must be either a constant value or a ml_genn.initializers.Initializer

  • allow_self_connections (bool) – If this connectivity is used to connect the same population to itself, should the same neuron be allowed to connect to itself?

  • delay (InitValue) – Connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet

class ml_genn.connectivity.OneToOne(weight, delay=0)

Bases: SparseBase

Sparse connectivity where each neuron in the source population is connected to the neuron with the same index in the target population (which must have the same size).

Parameters:
  • weight (InitValue) – Connection weights. Must be either a constant value, a ml_genn.initializers.Initializer or a sequence containing a weight for each neuron

  • delay (InitValue) – Connection delays

connect(source, target)

Called when two populations are connected to validate and potentially configure their shapes based on connectivity.

Parameters:
get_snippet(connection, supported_matrix_type)

Gets PyGeNN implementation of connectivity initializer

Parameters:
  • connection (Connection) – Connection this connectivity is to be applied to

  • supported_matrix_type (SupportedMatrixType) – GeNN synaptic matrix datatypes supported by current compiler

Return type:

ConnectivitySnippet