Skip to content

Instantly share code, notes, and snippets.

@drewnoff
Last active November 3, 2017 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drewnoff/41e44efebf43170405a3a5aac5902864 to your computer and use it in GitHub Desktop.
Save drewnoff/41e44efebf43170405a3a5aac5902864 to your computer and use it in GitHub Desktop.
import org.nd4s.Implicits._
import org.nd4j.linalg.factory.Nd4j
import org.nd4j.linalg.api.ops.impl.indexaccum.IAMax
object IndexAccumOpsMain {
def main(args: Array[String]) {
/** Gist for https://github.com/deeplearning4j/nd4j/issues/1916#issuecomment-314520715 **/
val myArray = Array(
Array(0,8,4),
Array(5,3,5),
Array(2,3,6)).toNDArray
val iAMaxAlongRows = Nd4j.getExecutioner().exec(new IAMax(myArray), 0)
val iAMaxAlongColumns = Nd4j.getExecutioner().exec(new IAMax(myArray), 1)
println(s"3x3 array:\n$myArray")
println(s"argmax of absolute values along dimension 0:\n$iAMaxAlongRows")
println(s"argmax of absolute values along dimension 1:\n$iAMaxAlongColumns")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment