I was trying to create a map that goes from integers to Nd4j arrays (as in INDArrays
) using the nd4s library. I'm struggling with this issue:
import org.nd4j.linalg.factory._
scala> Map(0 -> Nd4j.create(2))
<console>:17: error: type mismatch;
found : org.nd4j.linalg.api.ndarray.INDArray
required: Int
Map(0 -> Nd4j.create(2))
^
If I set the key type as string, it works:
scala> Map("0" -> Nd4j.create(2))
res28: scala.collection.immutable.Map[String,org.nd4j.linalg.api.ndarray.INDArray] = Map(0 -> [ 0.00, 0.00])
It works also by inverting key and value type.
I can't understand what is happening.