neupy.layers.base module

class neupy.layers.base.BaseLayer[source]

Base class for the layers.

Parameters:
name : str or None

Layer’s name. Can be used as a reference to specific layer. When value specified as None than name will be generated from the class name. Defaults to None

Attributes:
variables : dict

Variable names and their values. Dictionary can be empty in case if variables hasn’t been created yet.

Methods

variable(value, name, shape=None, trainable=True) Initializes variable with specified values.
get_output_shape(input_shape) Computes expected output shape from the layer based on the specified input shape.
output(*inputs, **kwargs) Propagetes input through the layer. The kwargs variable might contain additional information that propages through the network.
create_variables(*input_shapes)[source]
get_output_shape(input_shape)[source]
input_shape[source]
name = None[source]
options = {'name': Option(class_name='BaseLayer', value=Property(name="name"))}[source]
output_shape[source]
variable(value, name, shape=None, trainable=True)[source]
class neupy.layers.base.Identity[source]

Passes input through the layer without changes. Can be useful while defining residual networks in the network.

Parameters:
name : str or None

Layer’s name. Can be used as a reference to specific layer. When value specified as None than name will be generated from the class name. Defaults to None

Attributes:
variables : dict

Variable names and their values. Dictionary can be empty in case if variables hasn’t been created yet.

Methods

variable(value, name, shape=None, trainable=True) Initializes variable with specified values.
get_output_shape(input_shape) Computes expected output shape from the layer based on the specified input shape.
output(*inputs, **kwargs) Propagetes input through the layer. The kwargs variable might contain additional information that propages through the network.
get_output_shape(input_shape)[source]
options = {'name': Option(class_name='BaseLayer', value=Property(name="name"))}[source]
output(input, **kwargs)[source]
class neupy.layers.base.Input[source]

Layer defines network’s input.

Parameters:
shape : int or tuple

Shape of the input features per sample. Batch dimension has to be excluded from the shape.

name : str or None

Layer’s name. Can be used as a reference to specific layer. When value specified as None than name will be generated from the class name. Defaults to None

Examples

Feedforward Neural Network (FNN)

In the example, input layer defines network that expects 2D inputs (matrices). In other words, input to the network should be set of samples combined into matrix where each sample has 10 dimensional vector associated with it.

>>> from neupy.layers import *
>>> network = Input(10) >> Relu(5) >> Softmax(3)

Convolutional Neural Network (CNN)

In the example, input layer specified that we expect multiple 28x28 image as an input and each image should have single channel (images with no color).

>>> from neupy.layers import *
>>> network = join(
...     Input((28, 28, 1)),
...     Convolution((3, 3, 16)) >> Relu(),
...     Convolution((3, 3, 16)) >> Relu(),
...     Reshape()
...     Softmax(10),
... )
Attributes:
variables : dict

Variable names and their values. Dictionary can be empty in case if variables hasn’t been created yet.

Methods

variable(value, name, shape=None, trainable=True) Initializes variable with specified values.
get_output_shape(input_shape) Computes expected output shape from the layer based on the specified input shape.
output(*inputs, **kwargs) Propagetes input through the layer. The kwargs variable might contain additional information that propages through the network.
get_output_shape(input_shape)[source]
input_shape[source]
options = {'name': Option(class_name='BaseLayer', value=Property(name="name")), 'shape': Option(class_name='Input', value=TypedListProperty(name="shape"))}[source]
output(input, **kwargs)[source]
shape = None[source]