Package de.jungblut.math.activation
Class AbstractActivationFunction
- java.lang.Object
-
- de.jungblut.math.activation.AbstractActivationFunction
-
- All Implemented Interfaces:
ActivationFunction
- Direct Known Subclasses:
ElliotActivationFunction,LinearActivationFunction,LogActivationFunction,ReluActivationFunction,SigmoidActivationFunction,SoftMaxActivationFunction,SoftplusReluActivationFunction,StepActivationFunction,TanhActivationFunction
public abstract class AbstractActivationFunction extends java.lang.Object implements ActivationFunction
Implements the boiler plate code for applying functions on container classes like vectors and matrices by applying the function on every element. This implementation is aware of the type of the vector and matrix, so it is also optimized for sparse as well as dense types.- Author:
- thomas.jungblut
-
-
Constructor Summary
Constructors Constructor Description AbstractActivationFunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description de.jungblut.math.DoubleMatrixapply(de.jungblut.math.DoubleMatrix matrix)Applies the gradient of the activation function on each element in the given matrix.de.jungblut.math.DoubleVectorapply(de.jungblut.math.DoubleVector vector)Applies the activation function on each element in the given vector.de.jungblut.math.DoubleMatrixgradient(de.jungblut.math.DoubleMatrix matrix)Applies the gradient of the activation function on each element in the given matrix.de.jungblut.math.DoubleVectorgradient(de.jungblut.math.DoubleVector vector)Applies the gradient of the activation function on each element in the given vector.protected de.jungblut.math.DoubleMatrixnewInstance(de.jungblut.math.DoubleMatrix mat)protected de.jungblut.math.DoubleVectornewInstance(de.jungblut.math.DoubleVector v)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.jungblut.math.activation.ActivationFunction
apply, gradient
-
-
-
-
Method Detail
-
apply
public de.jungblut.math.DoubleVector apply(de.jungblut.math.DoubleVector vector)
Description copied from interface:ActivationFunctionApplies the activation function on each element in the given vector.- Specified by:
applyin interfaceActivationFunction- 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:ActivationFunctionApplies the gradient of the activation function on each element in the given matrix.- Specified by:
applyin interfaceActivationFunction- Parameters:
matrix- the matrix to apply this function on.- Returns:
- a new matrix that contains the gradient of the elements.
-
gradient
public de.jungblut.math.DoubleVector gradient(de.jungblut.math.DoubleVector vector)
Description copied from interface:ActivationFunctionApplies the gradient of the activation function on each element in the given vector.- Specified by:
gradientin interfaceActivationFunction- 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:ActivationFunctionApplies the gradient of the activation function on each element in the given matrix.- Specified by:
gradientin interfaceActivationFunction- Parameters:
matrix- the matrix to apply this function on.- Returns:
- a new matrix that contains the gradient of the elements.
-
newInstance
protected de.jungblut.math.DoubleMatrix newInstance(de.jungblut.math.DoubleMatrix mat)
-
newInstance
protected de.jungblut.math.DoubleVector newInstance(de.jungblut.math.DoubleVector v)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-