from akida.core import (Layer, ConvolutionalParams, Padding, PoolType,
ConvolutionKernelParams, NumNeuronsParams, StrideParams,
WeightBitsParams, PoolingParams, ActivationsParams,
"""Convolutional or "weight-sharing" layers are commonly used in visual
processing. However, the convolution operation is extremely useful in any
domain where translational invariance is required – that is, where localized
patterns may be of interest regardless of absolute position within the
input. The convolution implemented here is typical of that used in visual
processing, i.e., it is a 2D convolution (across the x- and y-dimensions),
but a 3D input with a 3D filter. No convolution occurs across the third
dimension; events from input feature 1 only interact with connections to
input feature 1 – likewise for input feature 2 and so on. Typically,
the input feature is the identity of the event-emitting neuron in the
Outputs are returned from convolutional layers as a list of events, that is,
as a triplet of x, y and feature (neuron index) values. Note that for a
single packet processed, each neuron can only generate a single event at a
given location, but can generate events at multiple different locations and
that multiple neurons may all generate events at a single location.
kernel_size (list): list of 2 integer representing the spatial
dimensions of the convolutional kernel.
filters (int): number of filters.
name (str, optional): name of the layer.
padding (:obj:`Padding`, optional): type of convolution.
kernel_stride (list, optional): list of 2 integer representing the
convolution stride (X, Y).
weights_bits (int, optional): number of bits used to quantize weights.
pool_size (list, optional): list of 2 integers, representing the window
size over which to take the maximum or the average (depending on
pool_type (:obj:`PoolType`, optional): pooling type
(None, Max or Average).
pool_stride (list, optional): list of 2 integers representing
the stride dimensions.
activation (bool, optional): enable or disable activation
threshold (int, optional): threshold for neurons to fire or
generate an event.
act_step (float, optional): length of the potential
act_bits (int, optional): number of bits used to quantize
the neuron response.
params = ConvolutionalParams(
ActivationsParams(activation, threshold, act_step,
PoolingParams(pool_size, pool_type, pool_stride),
# Call parent constructor to initialize C++ bindings
# Note that we invoke directly __init__ instead of using super, as
# specified in pybind documentation
Layer.__init__(self, params, name)
self = None