brainpy.layers module#

Basic ANN Layer Class#

Layer([name, mode])

Base class for a layer of artificial neural network.

Convolutional Layers#

Conv1d(in_channels, out_channels, kernel_size)

One-dimensional convolution.

Conv2d(in_channels, out_channels, kernel_size)

Two-dimensional convolution.

Conv3d(in_channels, out_channels, kernel_size)

Three-dimensional convolution.

Dropout Layers#

Dropout(prob[, seed, mode, name])

A layer that stochastically ignores a subset of inputs each training step.

Function Layers#

Activation(activate_fun[, name, mode])

Applies an activation function to the inputs

Flatten([name, mode])

Flattens a contiguous range of dims into 2D or 1D.

FunAsLayer(fun[, name, mode, has_shared])

Dense Connection Layers#

Dense(num_in, num_out[, W_initializer, ...])

A linear transformation applied over the last dimension of the input.

Normalization Layers#

BatchNorm1d(num_features[, axis, epsilon, ...])

1-D batch normalization [1]_.

BatchNorm2d(num_features[, axis, epsilon, ...])

2-D batch normalization [1]_.

BatchNorm3d(num_features[, axis, epsilon, ...])

3-D batch normalization [1]_.

LayerNorm(normalized_shape[, epsilon, ...])

Layer normalization (https://arxiv.org/abs/1607.06450).

GroupNorm(num_groups, num_channels[, ...])

Group normalization layer.

InstanceNorm(num_channels[, epsilon, ...])

Instance normalization layer.

NVAR Layers#

NVAR(num_in, delay[, order, stride, ...])

Nonlinear vector auto-regression (NVAR) node.

Pooling Layers#

MaxPool(kernel_size[, stride, padding, ...])

Pools the input by taking the maximum over a window.

MinPool(kernel_size[, stride, padding, ...])

Pools the input by taking the minimum over a window.

AvgPool(kernel_size[, stride, padding, ...])

Pools the input by taking the average over a window.

AvgPool1d(kernel_size[, stride, padding, ...])

Applies a 1D average pooling over an input signal composed of several input

AvgPool2d(kernel_size[, stride, padding, ...])

Applies a 2D average pooling over an input signal composed of several input

AvgPool3d(kernel_size[, stride, padding, ...])

Applies a 3D average pooling over an input signal composed of several input

MaxPool1d(kernel_size[, stride, padding, ...])

Applies a 1D max pooling over an input signal composed of several input

MaxPool2d(kernel_size[, stride, padding, ...])

Applies a 1D max pooling over an input signal composed of several input

MaxPool3d(kernel_size[, stride, padding, ...])

Applies a 1D max pooling over an input signal composed of several input

AdaptiveAvgPool1d(target_shape[, ...])

Adaptive one-dimensional average down-sampling.

AdaptiveAvgPool2d(target_shape[, ...])

Adaptive two-dimensional average down-sampling.

AdaptiveAvgPool3d(target_shape[, ...])

Adaptive three-dimensional average down-sampling.

AdaptiveMaxPool1d(target_shape[, ...])

Adaptive one-dimensional maximum down-sampling.

AdaptiveMaxPool2d(target_shape[, ...])

Adaptive two-dimensional maximum down-sampling.

AdaptiveMaxPool3d(target_shape[, ...])

Adaptive three-dimensional maximum down-sampling.

Reservoir Layers#

Reservoir(input_shape, num_out[, ...])

Reservoir node, a pool of leaky-integrator neurons with random recurrent connections [1]_.

Artificial Recurrent Layers#

RNNCell(num_in, num_out[, ...])

Basic fully-connected RNN core.

GRUCell(num_in, num_out[, Wi_initializer, ...])

Gated Recurrent Unit.

LSTMCell(num_in, num_out[, Wi_initializer, ...])

Long short-term memory (LSTM) RNN core.

VanillaRNN(*args, **kwargs)

Vanilla RNN.

GRU(*args, **kwargs)

GRU.

LSTM(*args, **kwargs)

LSTM.