-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ndarray: porting Python's autograd #274
Conversation
iblislin
commented
Sep 18, 2017
- https://mxnet.incubator.apache.org/tutorials/gluon/autograd.html
- https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/autograd.py
TODO:
|
We don't have custom operators yet so I don't thing we need user-defined differential functions, (it is actually a very hard problem to solve in Julia...) |
In Python, this shows that we only need one c api: About implementation of user funcs, maybe meta programming can help, just my imagination:
but not sure where is the pitfall of implementing it. |
found a problematic case: julia> x = mx.NDArray([1 2; 3 4])
mx.attach_grad(x)
y = mx.record() do
1x .* x
end
mx.backward(y)
julia> copy(mx.grad(x))
2×2 Array{Int64,2}:
1 4
9 16 It's gradient shoud be same as the one in commit message. |
I would leave custom functions completely out of the picture for now. The problems and pitfalls are plenty and I am currently not convinced there is a good way to implement them (outside of #173, which is currently stalled). In order to make customs function work you need to guarantee that they are never called asynchronously. |
which doc of mxnet c api can I consult? still can not understande what is the issue of aynchronous (io?). |
See the discussion and linked abandoned PRs in #166 |
Thanks! About custom OP, I think the brief summary is that libmxnet has a async engine when executing operators, so the Julia callback will be called in a different thread than the main thread. Due to the current incomplete support for multi-thread GC in Julia, a callback being called in a different thread from the C++ side is not guaranteed to function properly. |
Codecov Report
@@ Coverage Diff @@
## master #274 +/- ##
=========================================
+ Coverage 69.74% 70.94% +1.2%
=========================================
Files 25 26 +1
Lines 1963 2034 +71
=========================================
+ Hits 1369 1443 +74
+ Misses 594 591 -3
Continue to review full report at Codecov.
|
For record, here is an API changes: |
3146501
to
f3e7bd6
Compare
46b4548
to
e96f0ce
Compare
I ran into this error with recent libmxnet master, |
address #274 (comment) Although this patch cannot pass `@inferred`, but `code_warntype` give me this: ```julia end::MXNet.mx.NDArray{_,_} where _ where _ ``` And seems it doesn't hurt performance.
address dmlc#274 (comment) Although this patch cannot pass `@inferred`, but `code_warntype` give me this: ```julia end::MXNet.mx.NDArray{_,_} where _ where _ ``` And seems it doesn't hurt performance.
I think this PR is ready for review. |
I try to implement user-defined function. |
@pluskid need more time to review? |
travis failure is macOS build timeout. |