neupy.layers.GatedAverage

class neupy.layers.GatedAverage[source]

Layer uses applies weighted elementwise addition to multiple outputs. Weight can be control using separate input known as gate. Number of outputs from the gate has to be equal to the number of networks, since each value from the weight will be a weight per each network.

Layer expects gate as a first input, but it can be controlled with the gate_index parameter.

Parameters:
gate_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 first position.

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

>>> from neupy.layers import *
>>>
>>> gate = Input(10) >> Softmax(2)
>>> net1 = Input(20) >> Relu(10)
>>> net2 = Input(20) >> Relu(20) >> Relu(10)
>>>
>>> network = (gate | net1 | net2) >> GatedAverage()
>>> network
[(10,), (20,), (20,)] -> [... 8 layers ...] -> 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.
fail_if_shape_invalid(input_shapes)[source]
gate_index = None[source]
get_output_shape(*input_shapes)[source]
options = {'gate_index': Option(class_name='GatedAverage', value=IntProperty(name="gate_index")), 'name': Option(class_name='BaseLayer', value=Property(name="name"))}[source]
output(*inputs, **kwargs)[source]