neupy.layers.Elementwise

class neupy.layers.Elementwise[source]

Layer merges multiple input with elementwise function and generate single output. Each input to this layer should have exactly the same shape, otherwise it won’t be possible to apply elementwise operation.

Parameters:
merge_function : callable or {add, multiply}

Callable object that accepts two inputs and combines them in value using elementwise operation.

  • add - Sum all the inputs. Alias to tf.add.
  • multiply - Multiplies all the inputs. Alias to tf.multiply.
  • Custom function requires to have two input arguments.
def subtraction(x, y):
    return x - y

Defaults to add.

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 import layers
>>> network = (Input(10) | Input(10)) >> Elementwise('add')
[(?, 10), (?, 10)] -> [... 3 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.
get_output_shape(*input_shapes)[source]
merge_function = None[source]
options = {'merge_function': Option(class_name='Elementwise', value=FunctionWithOptionsProperty(name="merge_function")), 'name': Option(class_name='BaseLayer', value=Property(name="name"))}[source]
output(*inputs, **kwargs)[source]