neupy.layers.merge module

class neupy.layers.merge.Elementwise[source]

Merge multiple input layers in one with elementwise function.

Parameters:

merge_function : callable

Callable object that accepts multiple arguments and combine them in one with elementwise operation. Defaults to theano.tensor.add

name : str or None

Layer’s identifier. If name is equal to None than name will be generated automatically. Defaults to None.

Examples

>>> from neupy import layers
>>>
>>> input_1 = layers.Input(10)
>>> input_2 = layers.Input(10)
>>>
>>> network = [input_1, input_2] > layers.Elementwise()
>>>
>>> network.input_shape
[(10,), (10,)]
>>> network.output_shape
(10,)

Attributes

input_shape (tuple) Layer’s input shape.
output_shape (tuple) Layer’s output shape.
training_state (bool) Defines whether layer in training state or not.
parameters (dict) Trainable parameters.
graph (LayerGraph instance) Graphs that stores all relations between layers.

Methods

disable_training_state() Swith off trainig state.
initialize() Set up important configurations related to the layer.
merge_function = None[source]
options = {'merge_function': Option(class_name='Elementwise', value=CallableProperty(name="merge_function")), 'name': Option(class_name='BaseLayer', value=Property(name="name"))}[source]
output(*input_values)[source]

Return output base on the input value.

Parameters:input_value
output_shape[source]
validate(input_shapes)[source]

Validate input shape value before assigning it.

Parameters:input_shape : tuple with int
class neupy.layers.merge.Concatenate[source]

Concatenate multiple input layers in one based on the specified axes.

Parameters:

axis : int

The axis along which the inputs will be joined. Default is 1.

name : str or None

Layer’s identifier. If name is equal to None than name will be generated automatically. Defaults to None.

Examples

>>> from neupy import layers
>>>
>>> input_1 = layers.Input(10)
>>> input_2 = layers.Input(20)
>>>
>>> network = [input_1, input_2] > layers.Concatenate()
>>>
>>> network.input_shape
[(10,), (20,)]
>>> network.output_shape
(30,)

Attributes

input_shape (tuple) Layer’s input shape.
output_shape (tuple) Layer’s output shape.
training_state (bool) Defines whether layer in training state or not.
parameters (dict) Trainable parameters.
graph (LayerGraph instance) Graphs that stores all relations between layers.

Methods

disable_training_state() Swith off trainig state.
initialize() Set up important configurations related to the layer.
axis = None[source]
options = {'name': Option(class_name='BaseLayer', value=Property(name="name")), 'axis': Option(class_name='Concatenate', value=IntProperty(name="axis"))}[source]
output(*input_values)[source]

Return output base on the input value.

Parameters:input_value
output_shape[source]
validate(input_shapes)[source]

Validate input shape value before assigning it.

Parameters:input_shape : tuple with int
class neupy.layers.merge.GatedAverage[source]

Using output from the gated layer weights outputs from the other layers and sum them.

Parameters:

gating_layer_index : int

Input layers passed as a list and current variable specifies index in which it can find gating network. Defaults to 0, which means that it expects to see gating layer in zeros position.

name : str or None

Layer’s identifier. If name is equal to None than name will be generated automatically. Defaults to None.

Examples

>>> from neupy.layers import *
>>>
>>> gating_network = Input(10) > Softmax(2)
>>> network_1 = Input(20) > Relu(10)
>>> network_2 = Input(20) > Relu(20) > Relu(10)
>>>
>>> network = [gating_network, network_1, network_2] > GatedAverage()
>>> network
[(10,), (20,), (20,)] -> [... 8 layers ...] -> 10

Attributes

input_shape (tuple) Layer’s input shape.
output_shape (tuple) Layer’s output shape.
training_state (bool) Defines whether layer in training state or not.
parameters (dict) Trainable parameters.
graph (LayerGraph instance) Graphs that stores all relations between layers.

Methods

disable_training_state() Swith off trainig state.
initialize() Set up important configurations related to the layer.
gating_layer_index = None[source]
options = {'gating_layer_index': Option(class_name='GatedAverage', value=IntProperty(name="gating_layer_index")), 'name': Option(class_name='BaseLayer', value=Property(name="name"))}[source]
output(*input_values)[source]

Return output base on the input value.

Parameters:input_value
output_shape[source]
validate(input_shapes)[source]

Validate input shape value before assigning it.

Parameters:input_shape : tuple with int