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

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 19
DEFINE_int32(show_parameter_stats_period,
             0,
             "Whether to show parameter stats during training");
Z
zhangjinchao01 已提交
20

21
DEFINE_int32(dot_period, 1, "Print '.' every so many batches");
Z
zhangjinchao01 已提交
22

23
DEFINE_bool(use_old_updater, false, "Use the old RemoteParameterUpdater");
Z
zhangjinchao01 已提交
24

25
DECLARE_int32(num_passes);
Z
zhangjinchao01 已提交
26

27
DECLARE_bool(local);
Z
zhangjinchao01 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

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