All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nd4j.linalg.api.activation.BaseActivationFunction Maven / Gradle / Ivy

There is a newer version: 1.0.0-M2.1
Show newest version
package org.nd4j.linalg.api.activation;

import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.ops.ArrayOps;
import org.nd4j.linalg.ops.ElementWiseOp;

/**
 * Base activation function: mainly to give the function a canonical representation
 */
public abstract class BaseActivationFunction implements ActivationFunction {
    /**
     * Name of the function
     *
     * @return the name of the function
     */
    @Override
    public String type() {
        return getClass().getName();
    }

    @Override
    public boolean equals(Object o) {
        return o.getClass().getName().equals(type());
    }

    /**
     * The type()
     * @return
     */
    @Override
    public String toString() {
        return type();
    }


    /**
     * Returns the result of applying this function to {@code input}. This method is generally
     * expected, but not absolutely required, to have the following properties:
     * 

*

    *
  • Its execution does not cause any observable side effects. *
  • The computation is consistent with equals; that is, {@link Objects#equal * Objects.equal}{@code (a, b)} implies that {@code Objects.equal(function.apply(a), * function.apply(b))}. *
* * @param input * @throws NullPointerException if {@code input} is null and this function does not accept null * arguments */ @Override public INDArray apply(INDArray input) { ElementWiseOp op = new ArrayOps().from(input.dup()) .op(transformClazz()) .build(); op.exec(); return op.from(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy