Java Code Examples for org.nd4j.autodiff.samediff.SDVariable#isConstant()

The following examples show how to use org.nd4j.autodiff.samediff.SDVariable#isConstant() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegrationTestRunner.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
public static void assertSameDiffEquals(SameDiff sd1, SameDiff sd2){
    assertEquals(sd1.variableMap().keySet(), sd2.variableMap().keySet());
    assertEquals(sd1.getOps().keySet(), sd2.getOps().keySet());
    assertEquals(sd1.inputs(), sd2.inputs());

    //Check constant and variable arrays:
    for(SDVariable v : sd1.variables()){
        String n = v.name();
        assertEquals(n, v.getVariableType(), sd2.getVariable(n).getVariableType());
        if(v.isConstant() || v.getVariableType() == VariableType.VARIABLE){
            INDArray a1 = v.getArr();
            INDArray a2 = sd2.getVariable(n).getArr();
            assertEquals(n, a1, a2);
        }
    }

    //Check ops:
    for(SameDiffOp o : sd1.getOps().values()){
        SameDiffOp o2 = sd2.getOps().get(o.getName());
        assertEquals(o.getOp().getClass(), o2.getOp().getClass());
    }
}
 
Example 2
Source File: IntegrationTestRunner.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private static Map<String,INDArray> getConstantCopies(SameDiff sd){
    Map<String,INDArray> out = new HashMap<>();
    for(SDVariable v : sd.variables()){
        if(v.isConstant()){
            out.put(v.name(), v.getArr());
        }
    }
    return out;
}
 
Example 3
Source File: Enter.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public Enter(SameDiff sameDiff, String frameName, SDVariable input){
    super(sameDiff, new SDVariable[]{input});
    this.frameName = frameName;
    isConstant = input.isConstant();
}