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. Name Can be specified as:

  • String: Specified name will be used as a direct reference to the layer. For example, name=”fc”
  • Format string: Name pattern could be defined as a format string and specified field will be replaced with an index. For example, name=”fc{}” will be replaced with fc1, fc2 and so on. A bit more complex formatting methods are acceptable, for example, name=”fc-{:<03d}” will be converted to fc-001, fc-002, fc-003 and so on.
  • None: 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) Propagates input through the layer. The kwargs variable might contain additional information that propagates 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]