Python mod.bind() 失败

Python failure on mod.bind()

描述

必须为 one_hot 运算符设置索引类型,但我找不到设置它的位置或方法。

环境信息

------------Python 信息---------

版本:3.6.5

编译器:GCC 7.2.0

构建:('default', 'Apr 29 2018 16:14:56')

Arch : ('64bit', '')

------------点信息------------

版本:10.0.1

目录:/home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/pip

------------MXNet 信息------------

版本:1.3.0

目录:/home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet

提交哈希:247d57944f7a989d8f445856769e704b83765828

------------系统信息----------

平台:Linux-4.13.0-43-generic-x86_64-with-debian-stretch-sid

系统:Linux

节点:augustinasNT

发布:4.13.0-43-通用

版本:#48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018

错误信息:

RuntimeError: simple_bind 错误。参数:

数据:(1, 3, 112, 112)

运算符错误 one_hot0: [19:29:50] src/operator/tensor/./indexing_op.h:1002: 检查失败: (*in_attrs)[ 0] != -1 (-1 vs. -1) 必须为 one_hot operator

设置索引类型

堆栈跟踪返回 10 个条目:

[bt] (0) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x1d7c2a) [0x7fd3b2363c2a]

[bt] (1) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x1d8261) [0x7fd3b2364261]

[bt] (2) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x211641f) [0x7fd3b42a241f]

[bt] (3) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x2672116) [0x7fd3b47fe116]

[bt] (4) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x267b971) [0x7fd3b4807971]

[bt] (5) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x267c3ca) [0x7fd3b48083ca]

[bt] (6) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x266ca22) [0x7fd3b47f8a22]

[bt] (7) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x266d434) [0x7fd3b47f9434]

[bt] (8) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/site-packages/mxnet/libmxnet.so(MXExecutorSimpleBind+0x2378) [0x7fd3b47574a8]

[bt] (9) /home/augustinas/anaconda3/envs/mxnet/lib/python3.6/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7fd3cf795ec0]

因此查看 one_hot 的文档,您需要提供两个参数,indicesdepth,这两个参数都是必需的。 mx.symbol.one_hotmx.ndarray.one_hot 需要类似的参数,但 indices 将分别属于 Symbol 和 NDArray 类型。

1) indices(NDArray/Symbol 类型):要设置 on_value

的位置数组

2) depth(int类型):一个热维度的深度(即类的个数)

一个这样的例子:

one_hot([1,0,2,0], 3) = [[ 0.  1.  0.]
                         [ 1.  0.  0.]
                         [ 0.  0.  1.]
                         [ 1.  0.  0.]]