Class Swish

All Implemented Interfaces:
Activation

public class Swish extends AbstractActivation
Swish activation function. swish(x) = x * sigmoid(x).

Swish activation function which returns x*sigmoid(x). It is a smooth, non-monotonic function that consistently matches or outperforms ReLU on deep networks, it is unbounded above and bounded below.

Example Usage:

Operand<TFloat32> input = tf.constant(new float[]
                                   {-20, -1.0, 0.0, 1.0, 20});
Swish<TFloat32> swish = new Swish<>(tf);
Operand<TFloat32> result = swish.call(input);
// result = [-4.1223075e-08f, -2.6894143e-01f,  0.0000000e+00f,
//          7.3105860e-01f,  2.0000000e+01f ]

See Also:
  • Field Details

  • Constructor Details

    • Swish

      public Swish()
      Creates a Swish activation, swish(x) = x * sigmoid(x).

      Swish activation function which returns x*sigmoid(x). It is a smooth, non-monotonic function that consistently matches or outperforms ReLU on deep networks, it is unbounded above and bounded below.

    • Swish

      public Swish(Map<String,Object> config)
      Creates a new Swish from a configuration Map
      Parameters:
      config - the configuration map, this class does not use any of the entries in the configuration map
      Throws:
      IllegalArgumentException - if the configuration contains unsupported keys for this class or if the value for the name key does not match the name for the Activation
  • Method Details

    • swish

      public static <T extends TNumber> Operand<T> swish(Ops tf, Operand<T> input)
      Applies the Swish activation function, swish(x) = x * sigmoid(x).

      Example Usage:

      Operand<TFloat32> input = ...;
      Operand<TFloat32> result = Swish.swish(tf, input);
      
      Type Parameters:
      T - the data type for the input
      Parameters:
      tf - the TensorFlow Ops
      input - the input
      Returns:
      the Swish activation , @code swish(x) = x * sigmoid(x)}.
    • call

      public <T extends TNumber> Operand<T> call(Ops tf, Operand<T> input)
      Gets the calculation operation for the activation.
      Type Parameters:
      T - the data type of the input and the result
      Parameters:
      tf - the TensorFlow Ops
      input - the input tensor
      Returns:
      The operand for the activation
    • getConfig

      public Map<String,Object> getConfig()
      Gets a configuration map
      Specified by:
      getConfig in class AbstractActivation
      Returns:
      the configuration map
    • getName

      public String getName()
      Get the name of the activation as known by the TensorFlow Engine
      Specified by:
      getName in class AbstractActivation
      Returns:
      the name of the activation as known by the TensorFlow Engine