Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

ElementwiseLayer

ElementwiseLayer[f]
represents a net layer that applies a function f to every element of the input.

Details and OptionsDetails and Options

  • In ElementwiseLayer[f], the following functions f can be specified:
  • Ramp0 for x<0 and x for x>0
    LogisticSigmoid1/(1+exp(-x))
    Tanhhyperbolic tangent of x
  • ElementwiseLayer[][input] explicitly computes the output from applying the layer.
  • ElementwiseLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • ElementwiseLayer is typically used inside NetChain, NetGraph, etc.
  • ElementwiseLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a numerical tensor of arbitrary rank
    "Output"a numerical tensor with the same dimensions as the input
  • When it cannot be inferred from other layers in a larger net, the option "Input"->{n1,n2,} can be used to fix the input dimensions of ElementwiseLayer.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Create a net layer that computes Tanh of each input element:

In[1]:=
Click for copyable input
Out[1]=

Apply the layer to an input vector:

In[2]:=
Click for copyable input
Out[2]=

This is equivalent to:

In[3]:=
Click for copyable input
Out[3]=

Create a net layer with defined input size:

In[1]:=
Click for copyable input
Out[1]=

This layer automatically threads across a list of inputs:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2016
(11.0)