Skip to content

Commit

Permalink
rename two variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Yibing Liu committed May 23, 2017
1 parent 4d4593b commit 8c9ab5f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions paddle/parameter/FirstOrderOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,21 +305,22 @@ void AdamaxParameterOptimizer::update(const VectorPtr vecs[],
void OptimizerWithGradientClipping::update(const VectorPtr vecs[],
const ParameterConfig& config,
size_t sparseId) const {
real global_thres_ = optConfig_.gradient_clipping_threshold();
real local_thres_ = config.gradient_clipping_threshold();
real globalThreshold = optConfig_.gradient_clipping_threshold();
real localThreshold = config.gradient_clipping_threshold();

real threshold;
std::string field;
// Get the minimum of local and global threshold
// as the real threshold for clipping
if (global_thres_ > 0.0f && local_thres_ > 0.0f) {
threshold = global_thres_ < local_thres_ ? global_thres_ : local_thres_;
field = global_thres_ < local_thres_ ? "global" : "local";
} else if (global_thres_ > 0.0f) {
threshold = global_thres_;
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 {
threshold = local_thres_;
threshold = localThreshold;
field = "local";
}

Expand Down

0 comments on commit 8c9ab5f

Please sign in to comment.