public double clipGradients(){
  double gscale=1.0;
  if (clippingEnabled) {
    double gg=model.gradientL2norm();
    if (Double.isNaN(gg) || Double.isInfinite(gg)) {
      throw new RuntimeException("Magnitude of gradient is bad : " + gg);
    }
    if (gg > clipThreshold) {
      ++clips;
      gscale=clipThreshold / gg;
    }
  }
  return gscale;
}

public double clipGradients ( ) { double gscale = 1.0 ; if ( clippingEnabled ) { double gg = model . gradientL2norm ( ) ; if ( Double . isNaN ( gg ) || Double . isInfinite ( gg ) ) { throw new RuntimeException ( "Magnitude of gradient is bad : " + gg ) ; } if ( gg > clipThreshold ) { ++ clips ; gscale = clipThreshold / gg ; } } return gscale ; }
if clipping is enabled and the gradient is too big , return the amount to scale the gradient by ( otherwise 1 )
