org.nd4j.linalg.api.activation.Linear Maven / Gradle / Ivy
package org.nd4j.linalg.api.activation;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
import org.nd4j.linalg.ops.ElementWiseOp;
import org.nd4j.linalg.ops.transforms.Identity;
/**
* Linear activation function
* @author Adam Gibson
*/
public class Linear extends BaseActivationFunction {
/**
* The class used for transformation
*
* @return the class used for transformation
*/
@Override
public Class transformClazz() {
return Identity.class;
}
/**
* Name of the function
*
* @return the name of the function
*/
@Override
public String type() {
return "linear";
}
/**
* Applies the derivative of this function
*
* @param input the input to apply it to
* @return the derivative of this function applied to
* the input
*/
@Override
public INDArray applyDerivative(INDArray input) {
return Nd4j.ones(new int[]{input.rows(), input.columns()});
}
@Override
public INDArray apply(INDArray input) {
return input.dup();
}
}