zeroGrad method

void zeroGrad()

Resets the gradients of all parameters to zero.

This must be called at the end of each training iteration to prevent the gradients from one batch from accumulating into the next.

Implementation

void zeroGrad() {
  for (var param in parameters) {
    param.zeroGrad();
  }
}