Last active
November 3, 2017 04:29
-
-
Save drewnoff/41e44efebf43170405a3a5aac5902864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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