提交 c64a142c 编写于 作者: Y Yibing Liu

change the way of setting threshold

上级 8c9ab5f1
......@@ -310,18 +310,14 @@ void OptimizerWithGradientClipping::update(const VectorPtr vecs[],
real threshold;
std::string field;
// Get the minimum of local and global threshold
// as the real threshold for clipping
if (globalThreshold > 0.0f && localThreshold > 0.0f) {
threshold =
globalThreshold < localThreshold ? globalThreshold : localThreshold;
field = globalThreshold < localThreshold ? "global" : "local";
} else if (globalThreshold > 0.0f) {
threshold = globalThreshold;
field = "global";
} else {
// 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 maxAbsGrad = vecs[PARAMETER_GRADIENT]->getAbsMax();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册