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

org.nd4j.autodiff.functions.One Maven / Gradle / Ivy

There is a newer version: 0.9.1
Show newest version
package org.nd4j.autodiff.functions;

import org.nd4j.autodiff.AbstractIdentityFactory;
import org.nd4j.autodiff.ArrayField;
import org.nd4j.autodiff.Field;
import org.nd4j.autodiff.opstate.OpState;
import org.nd4j.autodiff.samediff.SDGraph;
import org.nd4j.linalg.api.ops.impl.transforms.arithmetic.MulOp;


public class One> extends Constant {


    public One(SDGraph graph,
               int[] shape,
               AbstractIdentityFactory i_factory) {
        super(graph,i_factory.one(shape),shape, i_factory);
        this.shape = shape;
    }




    @Override
    public DifferentialFunction mul(DifferentialFunction i_v) {
        DifferentialFunction dup = i_v.dup();
        if(i_v.getValue(true) instanceof ArrayField) {
            ArrayField arrayField = (ArrayField) i_v.getValue(true);
            addEdges(graph,
                    dup,
                    this,
                    new MulOp().name(),
                    OpState.OpType.TRANSFORM,
                    arrayField.getInput().getShape());
        }

        return dup;
    }



    @Override
    public DifferentialFunction dup() {
        return new One<>(graph, shape,getM_factory());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy