scala> val ndArray = (1d to 8d by 1).mkNDArray(Array(2,2,2),NDOrdering.C)
ndArray: org.nd4j.linalg.api.ndarray.INDArray =
[[[1.00,2.00]
 [3.00,4.00]]
  [[5.00,6.00]
 [7.00,8.00]]]

scala> ndArray.sliceP.map(s => s.rowP.map(r => r*r))
res12: org.nd4j.linalg.api.ndarray.INDArray =
[[[1.00,2.00]
 [9.00,16.00]]
  [[5.00,6.00]
 [49.00,64.00]]]

scala> ndArray.sliceP.map(s => s.columnP.map(r => r*r))
res13: org.nd4j.linalg.api.ndarray.INDArray =
[[[1.00,4.00]
 [9.00,16.00]]
  [[25.00,36.00]
 [49.00,64.00]]]