When using gluon,I can set grad_req = 'add' and use net.collect_params().zero_grad() to clear the gradient.I want to do the same thing by using mxnet.symbol. What should I do to set the grad_req and manually clear the gradient?Anyone help?
@zjuzuhe You can do that when you construct your executor (or Module). There is a grad_req option in the bind function, e.g, here https://mxnet.incubator.apache.org/api/python/module/module.html?highlight=grad_req#mxnet.module.BaseModule.bind
@sxjscience Thx.And if I set it to 'add' in the bind function,how could I set the gradients manually to zero after one epoch?I didn't find it in the website.
If you are using the executor interface, the gradient are in grad_dict(https://mxnet.incubator.apache.org/api/python/executor/executor.html#mxnet.executor.Executor.grad_dict). If you are using the Module interface, the gradients are in mod._exec_group.grad_arrays.
@zjuzuhe if your question has been answered, please consider closing the issue, thanks!
@indhub could you kindly close out this issue as it has been addressed?
Most helpful comment
If you are using the executor interface, the gradient are in
grad_dict(https://mxnet.incubator.apache.org/api/python/executor/executor.html#mxnet.executor.Executor.grad_dict). If you are using the Module interface, the gradients are inmod._exec_group.grad_arrays.