a,b);
&gt;&gt;&gt; c.backward();
&gt;&gt;&gt; console.log(a.grad);
//[[0.001, -0.99],
// [-0.13, 0.333]
// [-0.91,-0.044]]
&gt;&gt;&gt; a.zero_grad();
&gt;&gt;&gt; console.log(a.grad);
//[[0, 0],
// [0, 0]
// [0, 0]]
</code></pre>
<p><br></p>
<h2 id="tensorzero_grad_graph">tensor.zero_grad_graph</h2>
<p>Clears the gradients stored in this tensor, setting the gadients to zero, and does the same for every tensor that led to this one. This is used after the gradients have been used to update the parameters of 