Class Sigmoid

All Implemented Interfaces:
Activation

public class Sigmoid extends AbstractActivation
Sigmoid activation. sigmoid(x) = 1 / (1 + exp(-x)).

Applies the sigmoid activation function. For small values (<-5), sigmoid returns a value close to zero, and for large values (>5) the result of the function gets close to 1.

Sigmoid is equivalent to a 2-element Softmax, where the second element is assumed to be zero. The sigmoid function always returns a value between 0 and 1.

For example:

Operand<TFloat32> input = tf.constant(
         new float[] {-20f, -1.0f, 0.0f, 1.0f, 20f});
Sigmoid<TFloat32> sigmoid = new Sigmoid<>(tf);
Operand<TFloat32> result = sigmoid.call(input);
// result is [2.0611537e-09f, 2.6894143e-01f,
//                 5.0000000e-01f,7.3105860e-01f, 1.f]
  • Field Details

  • Constructor Details

    • Sigmoid

      public Sigmoid()
      Creates a Sigmoid activation.
    • Sigmoid

      public Sigmoid(Map<String,Object> config)
      Creates a new Exponential 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

    • sigmoid

      public static <T extends TNumber> Operand<T> sigmoid(Ops tf, Operand<T> input)
      Applies the Sigmoid activation function, sigmoid(x) = 1 / (1 + exp(-x)).

      Example Usage:

      Operand<TFloat32> input = ...;
      Operand<TFloat32> result = Sigmoid.sigmoid(tf, input);
      
      Type Parameters:
      T - the data type for the input
      Parameters:
      tf - the TensorFlow Ops
      input - the input
      Returns:
      the input, unmodified.
    • 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