kshitij12345 commented on a change in pull request #14779: [Don't merge] Fully
connected, higher order grad
URL: https://github.com/apache/incubator-mxnet/pull/14779#discussion_r291689294
##########
File path: tests/python/unittest/test_gluon.py
##########
@@ -915,6 +915,24 @@ def test_sequential_warning():
assert len(w) == 1
+@with_seed()
+def test_dense_backward():
+ import mxnet.autograd as ag
+ import mxnet.ndarray as nd
+ x = nd.array([[1,2,3,400]])
+ net = gluon.nn.Sequential()
+ with net.name_scope():
+ net.add(gluon.nn.Dense(1, in_units=x.shape[1]))
+ net.initialize(mx.initializer.Constant(.5))
+ params = [p.data() for p in net.collect_params().values()]
+ x.attach_grad()
+ with ag.record():
+ y = net.forward(x)
+ y_grad = ag.grad(y, x, create_graph=True, retain_graph=True)[0]
Review comment:
As per our discussion in #15120 , this should be `x_grad`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services