object LoadTest1 {
def main(args: Array[String]): Unit = {
var b = NDArray.array(Array(1, 2, 3),
shape = Shape(1, 3))
//var c = b.copy()
val a = NDArray.one_hot(Map("indices" -> NDArray.array(Array(1f, 2f, 3f), shape = Shape(1, 3)),
"on_value" -> 1,
"dtype" -> "float16",
"off_value" -> 0,
"depth" -> 4
// "out"->c
))(1)(1)
println(a)
println("-----------------------")
}
}
代码运行时出现如下错误:
Exception in thread "main" ml.dmlc.mxnet.MXNetError: Cannot find argument 'indices', Possible Arguments: depth : int, required Depth of the one hot dimension. on_value : double, optional, default=1 The value assigned to the locations represented by indices. off_value : double, optional, default=0 The value assigned to the locations not represented by indices. dtype : {'float16', 'float32', 'float64', 'int32', 'uint8'},optional, default='float32' 18/05/28 17:19:19 INFO util.NativeLibraryLoader: Deleting /var/folders/xh/cjnxxqwx05q4rmf3rz5zmt1r0000gn/T/mxnet4026866899089746779/mxnet-scala DType of the output 18/05/28 17:19:19 INFO util.NativeLibraryLoader: Deleting /var/folders/xh/cjnxxqwx05q4rmf3rz5zmt1r0000gn/T/mxnet4026866899089746779 , in operator one_hot(name="", depth="1", on_value="1", off_value="0", indices="ml.dmlc.mxnet.NDArray@c3b177e",
D型= “float16”) at ml.dmlc.mxnet.Base $ .checkCall(Base.scala:131) 在ml.dmlc.mxnet.NDArray $ .genericNDArrayFunctionInvoke(NDArray.scala:97) at ml.dmlc.mxnet.NDArray $ .one_hot(NDArray.scala:33) 在LoadTest $ .main(LoadTest.scala:22) 在LoadTest.main(LoadTest.scala)
I think I add the "indices". I am not very familiar with mxnet Scala, so what's wrong with this?
答案 0 :(得分:1)
val aa = NDArray.one_hot(NDArray.array(Array(1,2,3,4),shape = Shape(4)),4,1,0,"int32")
我发现它不需要Map作为param。就像它运行的代码一样。