dmlc / minpy

NumPy interface with mixed backend execution
https://minpy.readthedocs.io/en/latest/
Other
1.11k stars 112 forks source link

second grad error #165

Open kernel8liang opened 7 years ago

kernel8liang commented 7 years ago

Run autograd_tutorial example,

https://github.com/dmlc/minpy/blob/master/examples/tutorials/autograd_tutorial.ipynb

import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'

x = np.linspace(-10, 10, 200)
# plt.plot only takes ndarray as input. Explicitly convert MinPy Array into ndarray.
plt.plot(x.asnumpy(), foo(x).asnumpy(),
         x.asnumpy(), d_foo(x).asnumpy(),
         x.asnumpy(), d_2_foo(x).asnumpy(),
         x.asnumpy(), d_3_foo(x).asnumpy())
plt.show()

error below

AttributeError                            Traceback (most recent call last)
<ipython-input-5-317bda464833> in <module>()
      9 plt.plot(x.asnumpy(), foo(x).asnumpy(),
     10          x.asnumpy(), d_foo(x).asnumpy(),
---> 11          x.asnumpy(), d_2_foo(x).asnumpy(),
     12          x.asnumpy(), d_3_foo(x).asnumpy())
     13 plt.show()

AttributeError: 'float' object has no attribute 'asnumpy'
In [2]: mxnet.__version__
Out[2]: '0.9.4'

minpy version 0.33.

wangg12 commented 7 years ago

Related to #155, any fixes on this?

lryta commented 7 years ago

I will try to make a temporary solution in the weekend. In long term this part will be replaced by MXNet's NDArray subsystem which we are working on now.

jermainewang commented 7 years ago

We should still fix this. It is a quite important feature.

On Fri, Mar 24, 2017 at 2:40 PM, Larry Tang notifications@github.com wrote:

I will try to make a temporary solution in the weekend. In long term this part will be replaced by MXNet's NDArray subsystem which we are working on now.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dmlc/minpy/issues/165#issuecomment-289110532, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3qZWpgP4ne5oKfcXxhQUZcIp1TPErgks5rpA4wgaJpZM4MnwQf .

-- Minjie Wang New York University | Computer Science 715 Broadway, New York, NY, 10009

lryta commented 7 years ago

@jermainewang I found the reason now. Look at here: link. The function pushed into gradient record is unwrapped version. Which means that tape cannot record operations there. I think this change is due to performance concern. Should we fix it or wait autograd runtime? (By the way, does autograd runtime support higher order derivatives?

Taco-W commented 7 years ago

@lryta Do we have any follow-up on this?