Skip to content

Instantly share code, notes, and snippets.

@Leammas
Created January 12, 2017 08:21
Show Gist options
  • Select an option

  • Save Leammas/2944e4e36684c49c32b47143f6d06b1a to your computer and use it in GitHub Desktop.

Select an option

Save Leammas/2944e4e36684c49c32b47143f6d06b1a to your computer and use it in GitHub Desktop.
NDArrayUtil.toNDArray shape issue
import org.nd4j.linalg.util.NDArrayUtil
val arr = Array(Array(0, 0), Array(0, 0), Array(0, 0))
println(s"width: ${arr.length}") // 3
println(s"height: ${arr(0).length}") // 2
val ndArr = NDArrayUtil.toNDArray(arr)
println(s"width: ${ndArr.columns()}") // 3
println(s"height: ${ndArr.rows()}") // 1
println(ndArr.data().toString) // [0.0,0.0,0.0,0.0,0.0,0.0]
println(ndArr.shapeInfoToString()) // [1, 3]
println(ndArr.reshape(3, 1).shapeInfoToString()) // ok
println(ndArr.reshape(1, 6).shapeInfoToString()) // this one throws java.lang.IllegalStateException: Mis matched lengths: [6] != [3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment