TrainerInternalConfig.cpp 1.7 KB
Newer Older
Z
zhangjinchao01 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

#include "TrainerInternalConfig.h"

17 18
P_DEFINE_int32(show_parameter_stats_period,
               0,
Z
zhangjinchao01 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
               "Whether to show parameter stats during training");

P_DEFINE_int32(dot_period, 1, "Print '.' every so many batches");

P_DEFINE_bool(use_old_updater, false, "Use the old RemoteParameterUpdater");

P_DECLARE_int32(num_passes);

P_DECLARE_bool(local);

namespace paddle {

std::unique_ptr<TrainerInternalConfig> TrainerInternalConfig::createFromMode(
    GradientMachine::CreateMode mode) {
  auto config = new TrainerInternalConfig();
  config->mode = mode;
  config->local = FLAGS_local;
  config->use_gpu = FLAGS_use_gpu;
  config->trainer_count = FLAGS_trainer_count;
  config->show_param_stats_period = FLAGS_show_parameter_stats_period;
  config->trainer_id = FLAGS_trainer_id;
  config->log_period = FLAGS_log_period;
  config->dot_period = FLAGS_dot_period;
  config->num_passes = FLAGS_num_passes;
  config->use_old_updater = FLAGS_use_old_updater;
  config->loadsave_parameters_in_pserver = FLAGS_loadsave_parameters_in_pserver;

  return std::unique_ptr<TrainerInternalConfig>(config);
}

}  // namespace paddle