You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/10/18 15:02:21 UTC
[GitHub] kpot opened a new issue #8337: mx.autograd.grad's works or fails depending on use of slices
kpot opened a new issue #8337: mx.autograd.grad's works or fails depending on use of slices
URL: https://github.com/apache/incubator-mxnet/issues/8337
Hello guys,
Testing latest master branch 349ebc36ff3693376287098d280b11069dafbb55, I found that the same code using `autograd.grad` works fine or fails depending on whether I use full slice of a variable or not.
Working example:
```
import mxnet as mx
from mxnet import nd, autograd
ctx = mx.cpu()
a = mx.nd.array([1, 2, 3, 4], ctx=ctx)
a.attach_grad()
with autograd.record():
b = nd.sum(2 * (a ** 2)) # works without slicing
grads = autograd.grad(b, [a], create_graph=True, retain_graph=True)
da_sym = autograd.get_symbol(grads[0])
executor = da_sym.bind(ctx=ctx, args=[mx.nd.ones_like(b), a])
executor.forward()
print(executor.outputs[0])
```
but if I change the line `b = nd.sum(2 * (a ** 2))` with a technically identical expression `b = nd.sum(2 * (a[0:4] ** 2))` with variable `a` being sliced, the code begins to fail on `da_sym.bind(...)` with message
```
Traceback (most recent call last):
File "autograd_test.py", line 14, in <module>
executor = da_sym.bind(ctx=ctx, args=[mx.nd.ones_like(b), a])
File "/home/kpot/pyves/mxnet/lib/python3.6/site-packages/mxnet-0.12.0-py3.6.egg/mxnet/symbol/symbol.py", line 1666, in bind
ctypes.byref(handle)))
File "/home/kpot/pyves/mxnet/lib/python3.6/site-packages/mxnet-0.12.0-py3.6.egg/mxnet/base.py", line 146, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [19:32:23] src/executor/graph_executor.cc:451: InferShape pass cannot decide shapes for the following arguments (0s means unknown dimensions). Please consider providing them as inputs:
<just blank lines here>
Stack trace returned 10 entries:
[bt] (0) /home/kpot/pyves/mxnet/lib/python3.6/site-packages/mxnet-0.12.0-py3.6.egg/mxnet/libmxnet.so(_ZN4dmlc15LogMessageFatalD1Ev+0x3c) [0x7fe624ac93cc]
...
```
Environment: Ubuntu 14.04, latest master branch of mxnet (rev 349ebc36ff3693376287098d280b11069dafbb55) built from sources following [official instructions](http://mxnet.incubator.apache.org/get_started/install.html) with `make USE_OPENCV=1 USE_BLAS=openblas`
My initial goal was to try to build a computational graph for back-propagation so I could later use it with nnvm and thus launch it on OpenCL devices. I would appreciate any help, if my approach is wrong and I should try do this differently.
Full diagnostics:
```
----------Python Info----------
Version : 3.6.3
Compiler : GCC 4.8.4
Build : ('default', 'Oct 13 2017 11:22:10')
Arch : ('64bit', 'ELF')
------------Pip Info-----------
Version : 9.0.1
Directory : /home/kpot/pyves/mxnet/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Version : 0.12.0
Directory : /home/kpot/pyves/mxnet/lib/python3.6/site-packages/mxnet-0.12.0-py3.6.egg/mxnet
Traceback (most recent call last):
File "diagnose.py", line 108, in check_mxnet
with open(commit_hash, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/kpot/pyves/mxnet/lib/python3.6/site-packages/mxnet-0.12.0-py3.6.egg/mxnet/COMMIT_HASH'
----------System Info----------
Platform : Linux-3.13.0-133-generic-x86_64-with-debian-jessie-sid
system : Linux
node : eagle
release : 3.13.0-133-generic
version : #182-Ubuntu SMP Tue Sep 19 15:49:21 UTC 2017
----------Hardware Info----------
machine : x86_64
processor : x86_64
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 21
Model: 1
Stepping: 2
CPU MHz: 3800.000
BogoMIPS: 7634.99
Virtualization: AMD-V
L1d cache: 16K
L1i cache: 64K
L2 cache: 2048K
L3 cache: 4096K
NUMA node0 CPU(s): 0-3
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.1282 sec, LOAD: 2.0946 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.3062 sec, LOAD: 0.6475 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.3328 sec, LOAD: 1.3280 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.1119 sec, LOAD: 1.1860 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0681 sec, LOAD: 0.4717 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.1242 sec, LOAD: 0.3178 sec.
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services