Class SoftMaxActivationFunction

  • All Implemented Interfaces:
    ActivationFunction

    public final class SoftMaxActivationFunction
    extends AbstractActivationFunction
    Softmax activation that only works on vectors, because it needs to sum and divide the probabilities. In the case of matrices, the row vectors are taken.
    Author:
    thomas.jungblut
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double apply​(double input)
      Applies the activation function on the given element.
      de.jungblut.math.DoubleMatrix apply​(de.jungblut.math.DoubleMatrix matrix)
      Applies the gradient of the activation function on each element in the given matrix.
      de.jungblut.math.DoubleVector apply​(de.jungblut.math.DoubleVector vector)
      Applies the activation function on each element in the given vector.
      double gradient​(double input)
      Applies the gradient of the activation function on the given element.
      de.jungblut.math.DoubleMatrix gradient​(de.jungblut.math.DoubleMatrix matrix)
      Applies the gradient of the activation function on each element in the given matrix.
      de.jungblut.math.DoubleVector gradient​(de.jungblut.math.DoubleVector vector)
      Applies the gradient of the activation function on each element in the given vector.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SoftMaxActivationFunction

        public SoftMaxActivationFunction()
    • Method Detail

      • apply

        public double apply​(double input)
        Description copied from interface: ActivationFunction
        Applies the activation function on the given element.
      • apply

        public de.jungblut.math.DoubleVector apply​(de.jungblut.math.DoubleVector vector)
        Description copied from interface: ActivationFunction
        Applies the activation function on each element in the given vector.
        Specified by:
        apply in interface ActivationFunction
        Overrides:
        apply in class AbstractActivationFunction
        Parameters:
        vector - the vector to apply this function on.
        Returns:
        a new vector that contains the activated elements.
      • apply

        public de.jungblut.math.DoubleMatrix apply​(de.jungblut.math.DoubleMatrix matrix)
        Description copied from interface: ActivationFunction
        Applies the gradient of the activation function on each element in the given matrix.
        Specified by:
        apply in interface ActivationFunction
        Overrides:
        apply in class AbstractActivationFunction
        Parameters:
        matrix - the matrix to apply this function on.
        Returns:
        a new matrix that contains the gradient of the elements.
      • gradient

        public double gradient​(double input)
        Description copied from interface: ActivationFunction
        Applies the gradient of the activation function on the given element.
      • gradient

        public de.jungblut.math.DoubleVector gradient​(de.jungblut.math.DoubleVector vector)
        Description copied from interface: ActivationFunction
        Applies the gradient of the activation function on each element in the given vector.
        Specified by:
        gradient in interface ActivationFunction
        Overrides:
        gradient in class AbstractActivationFunction
        Parameters:
        vector - the vector to apply this function on.
        Returns:
        a new vector that contains the gradient of the elements.
      • gradient

        public de.jungblut.math.DoubleMatrix gradient​(de.jungblut.math.DoubleMatrix matrix)
        Description copied from interface: ActivationFunction
        Applies the gradient of the activation function on each element in the given matrix.
        Specified by:
        gradient in interface ActivationFunction
        Overrides:
        gradient in class AbstractActivationFunction
        Parameters:
        matrix - the matrix to apply this function on.
        Returns:
        a new matrix that contains the gradient of the elements.