Java Code Examples for org.nd4j.autodiff.samediff.SameDiff#putShapeForVarName()

The following examples show how to use org.nd4j.autodiff.samediff.SameDiff#putShapeForVarName() . 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: Constant.java    From nd4j with Apache License 2.0 5 votes vote down vote up
protected Constant(SameDiff sameDiff,
                   SDVariable i_v,
                   long[] shape,
                   boolean inPlace) {
    super();
    sameDiff.putShapeForVarName(i_v.getVarName(), shape);
    this.xVertexId = i_v.getVarName();
    this.inPlace = inPlace;
    this.sameDiff = sameDiff;


}
 
Example 2
Source File: Rank.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Override
public void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String, AttrValue> attributesForNode, GraphDef graph) {
    val name = TFGraphMapper.getInstance().getNodeName(nodeDef.getName());
    val input = initWith.getVariable(name);
    val outputVertex = input.getVarName();
    if (!initWith.isPlaceHolder(input.getVarName()) && initWith.shapeAlreadyExistsForVarName(outputVertex)) {
        val inputShape = initWith.getShapeForVarName(input.getVarName());
        val resultLength = Nd4j.scalar(inputShape.length);
        val thisResultId = outputVertex;
        initWith.putArrayForVarName(thisResultId, resultLength);
        initWith.putShapeForVarName(thisResultId, new long[]{1, 1});
    }
}