Interface ActivationFunction

All Superinterfaces:
Consumer<Tensor>
All Known Implementing Classes:
LeakyRelu, Linear, Relu, Sigmoid, SoftSign, Tanh

public interface ActivationFunction extends Consumer<Tensor>
Common base interface for all activation functions used in layers. Classes implementing this interface should provide methods for calculating value and first derivative of the activation function. Activation function performs non-linear transformation of its input before its sent to layer output. First derivative of a function shows how fast and in what direction function is changing if its input changes, and it is used by training algorithm. For more see https://en.wikipedia.org/wiki/Activation_function
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    accept(Tensor tensor)
     
    void
    apply(Tensor3D tensor, int channel)
     
    void
    apply(Tensor4D tensor, int batchIdx)
     
    void
    apply(Tensor tensor, int from, int to)
     
    Creates and returns specified type of activation function.
    float
    getPrime(float y)
    Returns the first derivative of activation function for specified output y
    float
    getValue(float x)
    Returns the value of activation function for specified input x

    Methods inherited from interface Consumer

    andThen
  • Method Details

    • getValue

      float getValue(float x)
      Returns the value of activation function for specified input x
      Parameters:
      x - input for activation
      Returns:
      value of activation function
    • apply

      void apply(Tensor3D tensor, int channel)
    • apply

      void apply(Tensor4D tensor, int batchIdx)
    • apply

      void apply(Tensor tensor, int from, int to)
    • accept

      default void accept(Tensor tensor)
      Specified by:
      accept in interface Consumer<Tensor>
    • getPrime

      float getPrime(float y)
      Returns the first derivative of activation function for specified output y
      Parameters:
      y - output of activation function
      Returns:
      first derivative of activation function
    • create

      static ActivationFunction create(ActivationType type)
      Creates and returns specified type of activation function. A factory method for creating activation functions;
      Parameters:
      type - type of the activation function
      Returns:
      returns instance of specified activation function type