Search code examples
arraysnd4j

Nd4j INDArray from boolean to int


If I have this array (its an INDArray but I'm simplifying the view) myArray = [[0, 0.7], [0, 0]], and I do this res = myArray.eq(0.7) I get res = [[false, true], [false, false]]

Is there a Nd4j method that can convert boolean INDArrays to 0/1 Arrays ? to get this [[0, 1], [0, 0]]


Solution

  • In INDArray there’s cast method available, it will give you exactly what you want - array of 0s and 1s