Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Numpy] Unique has not registered the gradient #18074

Closed
sxjscience opened this issue Apr 15, 2020 · 1 comment
Closed

[Numpy] Unique has not registered the gradient #18074

sxjscience opened this issue Apr 15, 2020 · 1 comment

Comments

@sxjscience
Copy link
Member

import mxnet as mx
from mxnet.gluon import nn, HybridBlock
mx.npx.set_np()

class Foo(HybridBlock):
    def hybrid_forward(self, F, x):
        y = F.np.unique(x)
        return y

foo = Foo()
foo.hybridize()
out = foo(mx.np.ones((10,)))
print(out.asnumpy())

Error message:

MXNetError: Traceback (most recent call last):
  File "../src/nnvm/gradient.cc", line 213
MXNetError: Operator _npi_unique is non-differentiable because it didn't register FGradient attribute.
@haojin2
Copy link
Contributor

haojin2 commented Apr 16, 2020

Root case is that the gradient for unique is not well-defined, so its gradient function was not registered at all in the first place. As per offline discussion with @sxjscience, we decide to add a zero grad node for the gradient.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants