public GradientClipping(T threshold) { this.Threshold = threshold; switch (this) { case GradientClipping <float> gradientClippingF: gradientClippingF.Update = () => GradientClippingF.Update(gradientClippingF.Threshold, gradientClippingF.FunctionParameters); break; case GradientClipping <double> gradientClippingD: gradientClippingD.Update = () => GradientClippingD.Update(gradientClippingD.Threshold, gradientClippingD.FunctionParameters); break; } }
public GradientClipping(T threshold) { this.Threshold = threshold; switch (this) { case GradientClipping <float> gradientClippingF: gradientClippingF.Update = () => OptimizerF.Update(gradientClippingF); gradientClippingF.UpdateFunctionParameters = (i) => GradientClippingF.UpdateFunctionParameters(gradientClippingF.Threshold, gradientClippingF.FunctionParameters[i]); break; case GradientClipping <double> gradientClippingD: gradientClippingD.Update = () => OptimizerD.Update(gradientClippingD); gradientClippingD.UpdateFunctionParameters = (i) => GradientClippingD.UpdateFunctionParameters(gradientClippingD.Threshold, gradientClippingD.FunctionParameters[i]); break; } }