Python failure on mod.bind()

Description

Index type must be set for one_hot operator, but I do not find where or how to set it.

Environment info

----------Python Info----------

Version : 3.6.5

Compiler : GCC 7.2.0

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

Arch : ('64bit', '')

------------Pip Info-----------

Version : 10.0.1

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

----------MXNet Info-----------

Version : 1.3.0

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

Commit Hash : 247d57944f7a989d8f445856769e704b83765828

----------System Info----------

Platform : Linux-4.13.0-43-generic-x86_64-with-debian-stretch-sid

system : Linux

node : augustinasNT

release : 4.13.0-43-generic

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

Error Message:

RuntimeError: simple_bind error. Arguments:

data: (1, 3, 112, 112)

Error in operator one_hot0: [19:29:50] src/operator/tensor/./indexing_op.h:1002: Check failed: (*in_attrs)[0] != -1 (-1 vs. -1) Index type must be set for one_hot operator

Stack trace returned 10 entries:

[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]

Upvotes: 0

Views: 236

Answers (1)

Thom Lane
Thom Lane

Reputation: 1063

So looking at the documentation of one_hot, you need to provide two arguments, indices and depth which are both required. Similar arguments are required for mx.symbol.one_hot and mx.ndarray.one_hot, but indices would be of type Symbol and NDArray respectively.

1) indices (of type NDArray/Symbol): array of locations where to set on_value

2) depth (of type int): depth of the one hot dimension (i.e. number of classes)

An example of this looks like:

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

Upvotes: 1

Related Questions