public static INDArray toOffsetZero ( INDArray arr ) { if ( arr . offset ( ) < 1 && arr . data ( ) . length ( ) == arr . length ( ) ) if ( arr . ordering ( ) == ' ' && arr . stride ( - 1 ) != 1 || arr . ordering ( ) == ' ' && arr . stride ( 0 ) != 1 ) return arr ; if ( arr . isRowVector ( ) ) { INDArray ret = Nd4j . create ( arr . shape ( ) ) ; for ( int i = 0 ; i < ret . length ( ) ; i ++ ) ret . putScalar ( i , arr . getDouble ( i ) ) ; return ret ; } INDArray ret = Nd4j . create ( arr . shape ( ) , arr . ordering ( ) ) ; ret . assign ( arr ) ; return ret ; }
Create a copy of the matrix where the new offset is zero