How is random_normal supposed to be used in scala


#1

I’m trying to use random_normal in the Symbol API. In scala.

How is it supposed to be used ?
The docs mentions that loc and scale could be Symbols and have a shape (that’s what I’m looking for). Although, when I try to use the symbol:

val mean:Symbol...
val std:Symbol...
Symbol.random_normal(i.output)(mean, std)()

MXNet complains that arguments are incorrect.

org.apache.mxnet.MXNetError: [23:24:15] src/core/symbolic.cc:290: Check failed: args.size() <= n_req (2 vs. 0) Incorrect number of arguments, requires 0, provided 2

Sounds like a bug to me. Or do I miss something ?


#2

I already opened a ticket https://github.com/apache/incubator-mxnet/issues/12140


#3

It looks like you’ve already found a information for this over at Github, but just going to show an example usage on this thread for reference, based on @lanking520’s answer:

val nd = NDArray.random_normal(Map("loc" -> 0, "scale" -> 1, "shape" -> Shape(2, 2)))()
nd.toArray.foreach(println)
1.1630787
0.4838046
0.29956347
0.15302546

Currently Scala API doesn’t have a Symbolic random module, as found in Python (e.g. mxnet.symbol.random.normal).


#5

And so, I discovered Symbol.sample_normal API… That solves my problem