提交 5cf2b2e8 编写于 作者: Y Yibing Liu

compress code

上级 c64a142c
......@@ -308,17 +308,10 @@ void OptimizerWithGradientClipping::update(const VectorPtr vecs[],
real globalThreshold = optConfig_.gradient_clipping_threshold();
real localThreshold = config.gradient_clipping_threshold();
real threshold;
std::string field;
// Use local gradient clipping threshold if it's enabled,
// otherwise using the global one.
if (localThreshold > 0.0f) {
threshold = localThreshold;
field = "local";
} else {
threshold = globalThreshold;
field = "global";
}
real threshold = localThreshold > 0.0f ? localThreshold : globalThreshold;
std::string field = localThreshold > 0.0f ? "local" : "global";
real maxAbsGrad = vecs[PARAMETER_GRADIENT]->getAbsMax();
if (maxAbsGrad > threshold) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册