From 3d4e61efd9c27779d7c9829ad7466a23cf108d05 Mon Sep 17 00:00:00 2001 From: xiexionghang Date: Tue, 27 Aug 2019 17:00:35 +0800 Subject: [PATCH] fix code style --- .../feed/accessor/epoch_accessor.cc | 2 +- .../feed/common/pslib_warpper.h | 14 ----- .../feed/common/runtime_environment.cc | 20 +++--- .../feed/common/runtime_environment.h | 20 ++++-- .../custom_trainer/feed/conf/gflags.conf | 2 +- .../feed/executor/multi_thread_executor.cc | 32 +++++++++- .../feed/executor/multi_thread_executor.h | 2 + .../feed/monitor/auc_monitor.cc | 57 ++++++++---------- .../custom_trainer/feed/monitor/auc_monitor.h | 12 ++-- .../custom_trainer/feed/monitor/monitor.h | 8 ++- .../feed/scripts/create_programs.py | 13 +++- .../custom_trainer/feed/scripts/example.py | 2 +- .../train/custom_trainer/feed/scripts/join.py | 6 +- .../feed/scripts/model/join/main_program | Bin 74960 -> 75510 bytes .../feed/scripts/model/join/model.yaml | 5 ++ .../feed/scripts/model/join/startup_program | Bin 29630 -> 29839 bytes .../feed/scripts/model/join/test_program | Bin 33293 -> 33568 bytes .../feed/scripts/model/update/main_program | Bin 55463 -> 55859 bytes .../feed/scripts/model/update/model.yaml | 5 ++ .../feed/scripts/model/update/startup_program | Bin 18963 -> 19095 bytes .../feed/scripts/model/update/test_program | Bin 23900 -> 24098 bytes .../custom_trainer/feed/scripts/update.py | 6 +- 22 files changed, 124 insertions(+), 82 deletions(-) diff --git a/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc b/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc index 6ef4c398..dd2d0e95 100644 --- a/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc +++ b/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc @@ -126,7 +126,7 @@ namespace feed { case ModelSaveWay::ModelSaveInferenceBase: return is_last_epoch(epoch_id); case ModelSaveWay::ModelSaveTrainCheckpoint: - return ((epoch_id / SecondsPerHour) % 8) == 0; + return delta_id(epoch_id) % 8 == 0; } return false; } diff --git a/paddle/fluid/train/custom_trainer/feed/common/pslib_warpper.h b/paddle/fluid/train/custom_trainer/feed/common/pslib_warpper.h index d35aa9a7..10406d2b 100644 --- a/paddle/fluid/train/custom_trainer/feed/common/pslib_warpper.h +++ b/paddle/fluid/train/custom_trainer/feed/common/pslib_warpper.h @@ -1,17 +1,3 @@ -/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. - -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. */ - #pragma once // Hide BLOG diff --git a/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.cc b/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.cc index ee9b0c73..415f9955 100644 --- a/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.cc +++ b/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.cc @@ -139,14 +139,13 @@ public: ar.SetCursor(ar.Buffer()); MPI_Bcast(ar.Buffer(), len, MPI_BYTE, root_id, node_info.mpi_comm); } - - virtual double all_reduce_ele(double x) { - double tot = 0.0; - MPI_Allreduce(&x, &tot, 1, mpi_type_trait::type(), MPI_SUM, MPI_COMM_WORLD); - return tot; - } - virtual void all_reduce_arr(double* x, int n) { - MPI_Allreduce(MPI_IN_PLACE, x, n, mpi_type_trait::type(), MPI_SUM, MPI_COMM_WORLD); + virtual void all_reduce_in_place(double* x, int n, ReduceOperator op, EnvironmentRole role) { + auto& node_info = mpi_node_info(role); + if (op == ReduceOperator::SUM) { + MPI_Allreduce(MPI_IN_PLACE, x, n, MPI_DOUBLE, MPI_SUM, node_info.mpi_comm); + } else { + CHECK(false) << "unsupport operator"; + } } protected: @@ -201,10 +200,7 @@ public: virtual void bcast(paddle::framework::BinaryArchive& ar, int root_id, EnvironmentRole role) { return; } - virtual double all_reduce_ele(double x) { - return x; - } - virtual void all_reduce_arr(double* x, int n) { + virtual void all_reduce_in_place(double* x, int n, ReduceOperator op, EnvironmentRole role) { return; } protected: diff --git a/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.h b/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.h index aaf602bc..993ac36d 100644 --- a/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.h +++ b/paddle/fluid/train/custom_trainer/feed/common/runtime_environment.h @@ -27,7 +27,7 @@ enum class EnvironmentLogType { ALL_LOG = 1 //所有节点都会对外输出 }; -//保持该枚举值的连续递增,且ALL在尾部 +// 保持该枚举值的连续递增,且ALL在尾部 enum class EnvironmentRole { WORKER = 0, //训练Worker PSERVER = 1, //参数服务器 @@ -35,6 +35,11 @@ enum class EnvironmentRole { ALL = 2 //所有角色,请保持在枚举尾部 }; +// Reduce的操作类型 +enum class ReduceOperator { + SUM = 0 //求和 +}; + class RuntimeEnvironment { public: RuntimeEnvironment(); @@ -72,10 +77,15 @@ public: virtual void barrier(EnvironmentRole role) = 0; // bcast 广播 virtual void bcast(paddle::framework::BinaryArchive& ar, int root_id, EnvironmentRole role) = 0; - // all_reduce sum element 规约元素 - virtual double all_reduce_ele(double x) = 0; - // all_reduce sum array 规约数组 - virtual void all_reduce_arr(double* x, int n) = 0; + // 全局reduce操作, 返回reduce结果 + virtual double all_reduce(double x, ReduceOperator op, EnvironmentRole role) { + double result = x; + all_reduce_in_place(&result, 1, op, role); + return result; + } + // 全局reduce,就地执行 + virtual void all_reduce_in_place(double* x, int n, + ReduceOperator op, EnvironmentRole role) = 0; // 接口只允许在主线程调用 End protected: virtual void print_log(EnvironmentRole role, EnvironmentLogType type, diff --git a/paddle/fluid/train/custom_trainer/feed/conf/gflags.conf b/paddle/fluid/train/custom_trainer/feed/conf/gflags.conf index c7b8a663..96e03e71 100644 --- a/paddle/fluid/train/custom_trainer/feed/conf/gflags.conf +++ b/paddle/fluid/train/custom_trainer/feed/conf/gflags.conf @@ -1,5 +1,5 @@ -log_dir=log --v=4 +-v=2 -logbufsecs=0 -pslib_push_dense_merge_limit=1 -pslib_push_sparse_merge_limit=1 diff --git a/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.cc b/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.cc index 27c7127b..309e453a 100644 --- a/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.cc +++ b/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.cc @@ -1,4 +1,5 @@ #include "paddle/fluid/train/custom_trainer/feed/io/file_system.h" +#include "paddle/fluid/train/custom_trainer/feed/monitor/monitor.h" #include "paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.h" namespace paddle { @@ -63,11 +64,23 @@ int MultiThreadExecutor::initialize(YAML::Node exe_config, } } + // Monitor组件 + for (const auto& monitor_config : _model_config["monitor"]) { + auto monitor_class = monitor_config["class"].as(); + auto* monitor_ptr = CREATE_INSTANCE(Monitor, monitor_class); + _monitors.emplace_back(monitor_ptr); + CHECK(monitor_ptr->initialize(monitor_config, context_ptr) == 0) + << "Monitor init Failed, class:" << monitor_class; + } return ret; } paddle::framework::Channel MultiThreadExecutor::run( paddle::framework::Channel input, const DataParser* parser) { + + uint64_t epoch_id = _trainer_context->epoch_accessor->current_epoch_id(); + + // 输入流 PipelineOptions input_pipe_option; input_pipe_option.need_hold_input_data = true; input_pipe_option.batch_size = 1; @@ -97,6 +110,7 @@ paddle::framework::Channel MultiThreadExecutor::run( return 0; }); + // 训练流 PipelineOptions train_pipe_option; train_pipe_option.input_output_rate = 1; train_pipe_option.thread_num = _train_thread_num; @@ -108,19 +122,20 @@ paddle::framework::Channel MultiThreadExecutor::run( auto* executor = _thread_executors[thread_idx].get(); size_t& out_idx = *out_num; for (out_idx = 0; out_idx < in_num; ++out_idx) { - //CHECK(executor->run(in_items[out_idx].get()) == 0); + CHECK(executor->run(in_items[out_idx].get()) == 0); out_items[out_idx] = std::move(in_items[out_idx]); } return 0; }); + // 梯度回传流 PipelineOptions gradient_pipe_option; gradient_pipe_option.input_output_rate = 1; gradient_pipe_option.thread_num = _push_gradient_thread_num; gradient_pipe_option.buffer_batch_count = 2 * _train_thread_num; auto gradient_pipe = std::make_shared>(); gradient_pipe->connect_to(*train_pipe, gradient_pipe_option, - [this] (ScopePoolObj* in_items, size_t in_num, + [epoch_id, this] (ScopePoolObj* in_items, size_t in_num, int* out_items, size_t* out_num, size_t thread_idx) -> int { size_t& out_idx = *out_num; for (out_idx = 0; out_idx < in_num; ++out_idx) { @@ -134,14 +149,27 @@ paddle::framework::Channel MultiThreadExecutor::run( out_items[out_idx] = _input_accessors[i]-> backward(samples, sample_num, scope); } + for (auto& monitor : _monitors) { + monitor->add_data(epoch_id, this, samples, sample_num); + } delete[] samples; // 所有pipe完成后,再回收sample } return 0; }); + // 等待训练流结束 std::vector gradient_status; while (gradient_pipe->read(gradient_status) > 0) { } + // 输出相关监控&统计项 + for (auto& monitor : _monitors) { + if (monitor->need_compute_result(epoch_id)) { + monitor->compute_result(); + VLOG(2) << "[Monitor]" << _train_exe_name << ", monitor:" << monitor->get_name() + << ", result:" << monitor->format_result(); + monitor->reset(); + } + } return input_pipe->backup_channel(); } diff --git a/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.h b/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.h index 68c9f88f..12792945 100644 --- a/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.h +++ b/paddle/fluid/train/custom_trainer/feed/executor/multi_thread_executor.h @@ -8,6 +8,7 @@ namespace paddle { namespace custom_trainer { namespace feed { +class Monitor; typedef paddle::ps::ObjectPool<::paddle::framework::Scope>::PooledObject ScopePoolObj; class MultiThreadExecutor { @@ -50,6 +51,7 @@ protected: YAML::Node _model_config; std::string _train_exe_name; TrainerContext* _trainer_context = nullptr; + std::vector> _monitors; std::vector> _thread_executors; std::vector> _input_accessors; std::map> _table_to_accessors; diff --git a/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.cc b/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.cc index cb472fe7..a5122849 100644 --- a/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.cc +++ b/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.cc @@ -6,8 +6,8 @@ namespace feed { int AucMonitor::initialize(const YAML::Node& config, std::shared_ptr context_ptr) { Monitor::initialize(config, context_ptr); + _target_idx = config["target_idx"].as(); _target_name = config["target"].as(); - _label_name = config["label"].as(); _table_size = 1000000; if (config["table_size"]) { _table_size = config["table_size"].as(); @@ -15,45 +15,34 @@ int AucMonitor::initialize(const YAML::Node& config, std::shared_ptr(); - if (interval != 3600 || interval != 86400) { - LOG(FATAL) << " AucMonitor config compute_interval just support hour: 3600 or day: 86400. "; - return -1; - } - _compute_interval = interval; + _compute_interval = config["compute_interval"].as(); + CHECK(_compute_interval % 60 == 0); } + return 0; } -void AucMonitor::add_data(int epoch_id, const Executor* executor, SampleInstance* instance, size_t num) { - if (executor == nullptr - || instance == nullptr - || instance->predicts.empty() - || instance->labels.empty() - || num <= 0 - || instance->predicts.size() < num - || instance->labels.size() < num) { - LOG(FATAL) << "AucMonitor add predict data is invalid, predicts or labels is empty, num[" << num << "]"; - return; - } +void AucMonitor::add_data(int epoch_id, + const MultiThreadExecutor* executor, SampleInstance* samples, size_t num) { + CHECK(num > 0); std::lock_guard lock(_mutex); for (int i = 0; i < num; ++i) { - add_unlocked(instance->predicts[i], std::lround(instance->labels[i])); + auto& instance = samples[i]; + add_unlocked(instance.predicts[_target_idx], std::lround(instance.labels[_target_idx])); } } -bool AucMonitor::need_compute_result(int epoch_id, EpochAccessor* accessor) { - CHECK(accessor != nullptr); - uint64_t epoch_time = accessor->epoch_timestamp(epoch_id); - if (epoch_time % _compute_interval != 0) { - return false; - } - return true; +bool AucMonitor::need_compute_result(int epoch_id) { + CHECK(_epoch_accessor != nullptr); + uint64_t epoch_time = _epoch_accessor->epoch_timestamp(epoch_id); + return epoch_time % _compute_interval == 0; } void AucMonitor::compute_result() { + auto* environment = Monitor::_context_ptr->environment.get(); double* table[2] = {&_table[0][0], &_table[1][0]}; for (int i = 0; i < 2; i++) { - Monitor::_context_ptr->environment->all_reduce_arr(table[i], _table_size); + environment->all_reduce_in_place(table[i], + _table_size, ReduceOperator::SUM, EnvironmentRole::WORKER); } double area = 0; double fp = 0; @@ -66,11 +55,14 @@ void AucMonitor::compute_result() { tp = newtp; } _auc = area / (fp * tp); - _mae = Monitor::_context_ptr->environment->all_reduce_ele(_local_abserr) / (fp + tp); - _rmse = sqrt(Monitor::_context_ptr->environment->all_reduce_ele(_local_sqrerr) / (fp + tp)); + _mae = environment->all_reduce(_local_abserr, + ReduceOperator::SUM, EnvironmentRole::WORKER) / (fp + tp); + _rmse = sqrt(environment->all_reduce(_local_sqrerr, + ReduceOperator::SUM, EnvironmentRole::WORKER) / (fp + tp)); _rmse = sqrt(_rmse / (fp + tp)); _actual_ctr = tp / (fp + tp); - _predicted_ctr = Monitor::_context_ptr->environment->all_reduce_ele(_local_pred) / (fp + tp); + _predicted_ctr = environment->all_reduce(_local_pred, + ReduceOperator::SUM, EnvironmentRole::WORKER) / (fp + tp); _size = fp + tp; calculate_bucket_error(); } @@ -81,9 +73,8 @@ std::string AucMonitor::format_result() { copc = _actual_ctr / _predicted_ctr; } char buf[10240]; - snprintf(buf, 10240 * sizeof(char), "%s: AUC=%.6f BUCKET_ERROR=%.6f MAE=%.6f RMSE=%.6f " + snprintf(buf, 10240 * sizeof(char), "AUC=%.6f BUCKET_ERROR=%.6f MAE=%.6f RMSE=%.6f " "Actual CTR=%.6f Predicted CTR=%.6f COPC=%.6f INS Count=%.0f", - Monitor::_name.c_str(), _auc, _bucket_error, _mae, @@ -157,6 +148,8 @@ void AucMonitor::reset() { _local_pred = 0; } +REGIST_CLASS(Monitor, AucMonitor); + } // namespace feed } // namespace custom_trainer } // namespace paddle diff --git a/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.h b/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.h index aa2bd34c..51af181f 100644 --- a/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.h +++ b/paddle/fluid/train/custom_trainer/feed/monitor/auc_monitor.h @@ -18,13 +18,11 @@ public: std::shared_ptr context_ptr) override; //添加一项记录,统计内容Monitor自行从Executor按需获取 - virtual void add_data(int epoch_id, - const Executor* executor, - SampleInstance* instance, - size_t num); + virtual void add_data(int epoch_id, const MultiThreadExecutor* executor, + SampleInstance* samples, size_t num); //是否开始结果统计 - virtual bool need_compute_result(int epoch_id, EpochAccessor* accessor); + virtual bool need_compute_result(int epoch_id); //统计当前结果 virtual void compute_result(); //基于现有结果,输出格式化的统计信息 @@ -33,7 +31,7 @@ public: virtual void reset(); protected: - std::string _label_name; + uint32_t _target_idx; std::string _target_name; std::string _name; std::string _output_var; @@ -47,7 +45,7 @@ protected: double _bucket_error; int _table_size; void add_unlocked(double pred, int label); - + private: void calculate_bucket_error(); void set_table_size(int table_size); diff --git a/paddle/fluid/train/custom_trainer/feed/monitor/monitor.h b/paddle/fluid/train/custom_trainer/feed/monitor/monitor.h index d205c23d..4a963634 100644 --- a/paddle/fluid/train/custom_trainer/feed/monitor/monitor.h +++ b/paddle/fluid/train/custom_trainer/feed/monitor/monitor.h @@ -9,6 +9,7 @@ namespace paddle { namespace custom_trainer { namespace feed { +class MultiThreadExecutor; class Monitor { public: @@ -19,14 +20,16 @@ public: std::shared_ptr context_ptr) { _name = config["name"].as(); _context_ptr = context_ptr; + _epoch_accessor = _context_ptr->epoch_accessor.get(); return 0; } //添加一项记录,统计内容Monitor自行从Executor按需获取 - virtual void add_data(int epoch_id, const Executor* executor, SampleInstance* instance, size_t num) = 0; + virtual void add_data(int epoch_id, const MultiThreadExecutor* executor, + SampleInstance* samples, size_t num) = 0; //是否对于当前epoch_id进行结果统计 - virtual bool need_compute_result(int epoch_id, EpochAccessor* accessor) = 0; + virtual bool need_compute_result(int epoch_id) = 0; //统计当前结果 virtual void compute_result() = 0; //基于现有结果,输出格式化的统计信息 @@ -40,6 +43,7 @@ public: protected: std::string _name; + EpochAccessor* _epoch_accessor = nullptr; std::shared_ptr _context_ptr; }; diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/create_programs.py b/paddle/fluid/train/custom_trainer/feed/scripts/create_programs.py index af0de70d..396381ce 100644 --- a/paddle/fluid/train/custom_trainer/feed/scripts/create_programs.py +++ b/paddle/fluid/train/custom_trainer/feed/scripts/create_programs.py @@ -95,7 +95,8 @@ class ModelBuilder: main_program = fluid.Program() startup_program = fluid.Program() with fluid.program_guard(main_program, startup_program): - input_accessor, sparses, inputs, outputs = self._inference() + #TODO return dict maybe better ? + input_accessor, sparses, inputs, outputs, monitors = self._inference() test_program = main_program.clone(for_test=True) loss, labels = self._loss_function(*outputs) @@ -134,7 +135,11 @@ class ModelBuilder: accessor["input"] = [ {"label_name": label.name, "shape": label.shape, "output_name": output.name } for (label, output) in zip(labels, outputs) ] - + + for monitor in monitors: + idx = outputs.index(monitor['target']) + monitor["target_idx"] = idx + monitor["target"] = outputs[idx].name model_desc_path = os.path.join(self._save_path, 'model.yaml') model_desc = { @@ -142,7 +147,9 @@ class ModelBuilder: 'outputs': [{"name": var.name, "shape": var.shape} for var in outputs], 'labels': [{"name": var.name, "shape": var.shape} for var in labels], 'loss': loss.name, - 'input_accessor': input_accessor + 'input_accessor': input_accessor, + 'monitor': monitors, + 'aa_Attention' : 'Do Not Modify This File Manually, Unless You Really Know It' } with open(model_desc_path, 'w') as f: diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/example.py b/paddle/fluid/train/custom_trainer/feed/scripts/example.py index 4805e853..c06b53b3 100644 --- a/paddle/fluid/train/custom_trainer/feed/scripts/example.py +++ b/paddle/fluid/train/custom_trainer/feed/scripts/example.py @@ -32,7 +32,7 @@ def inference(): net = fluid.layers.fc(net, 128, act='relu', name='fc_7') ctr_output = fluid.layers.fc(net, 1, act='sigmoid', name='ctr') - return [cvm_input], [ctr_output] + return [], [], [cvm_input], [ctr_output], monitors def loss_function(ctr_output): """ diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/join.py b/paddle/fluid/train/custom_trainer/feed/scripts/join.py index f96bdaa4..1df4cf29 100644 --- a/paddle/fluid/train/custom_trainer/feed/scripts/join.py +++ b/paddle/fluid/train/custom_trainer/feed/scripts/join.py @@ -46,7 +46,11 @@ def inference(): { "class": "DenseInputAccessor", "input": "sums", "table_id": 2, "need_gradient": True, "async_pull": True}, { "class": "LabelInputAccessor", "input": "labels"} ] - return accessors, [sparse_cvm], [cvm_input], [ctr_output] + monitors = [ + { "name": "epoch_auc", "class": "AucMonitor", "target": ctr_output, "compute_interval": 600 }, + { "name": "day_auc", "class": "AucMonitor", "target": ctr_output, "compute_interval": 86400 } + ] + return accessors, [sparse_cvm], [cvm_input], [ctr_output], monitors def loss_function(ctr_output): """ diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/model/join/main_program b/paddle/fluid/train/custom_trainer/feed/scripts/model/join/main_program index 9d5a954648abd1895f32c5aab6ec502ec6767695..201006fe19658ec040ba7caeadc0a21a74743431 100644 GIT binary patch delta 2789 zcmb8xZAep57zc2kbCYNBrYIB?rR+mu7#LWHnOXOqyL)euaG!l0`*VK#pL3p_(O0&) zVVmHX8SWC^JK+b8I~QS4?mFBE^64ZGu&aP$`DOMjPeoPb*_x{Jm=xIqIp{xdkmYX0 z61NW{DajDRk(8$pRC0MtT9XEaRyna8USo9{vKw~!g+E;&h1^GA7Q5Y5Fd;{4=V%ML zebA19jBW^qlUBh^MuP3yq{70*E1*KK3UJiLEFFbS8!dml+sE4NczMB#4cT{NtzpqO z%N#Gww!$5oYQOtd}%d_O}&Ui^I0C~WmP%Vqd}mX?|{LWa{i&KQMJB5Gkx z?6x{J z5(I1wS!R^N7I6RdYM4}p#yG=uLF^5Cs0w%q60*u!9_^8GEC zeDCq!nH2=}CXY=}yq#fM=PW5ZJIfj%Aq5*#m#DM7n zEye3okV^wD+&h?np`lqFN?27n%mKVMszOOaMnm3zYa%I=Om9-&{2>wOBQt>Bs8Jzh zC~LZ$NmEBk#VV9vPRDf0d?EySchA2XLdw6ICVcbV6p~W9ux!B;5`tWK;$s{)WK;Dv8` WT3e~JC)~Cka#>ujQ&H;61lJ#f+Ugkq delta 2428 zcma*pT}TvB6bEq5?4qu#yK3PEo6y>a4;G|7n0p(coDu4^erFcHr=`6sgT3 zKX*a~!tzFFQ3^{6B+Pg1H7rT)t%L!rTY>OfnJcRYUw<4l0XMF$aJV7?rtwYMNq9|4 zg8X}vu+(gk6BEFNGwFolO$3i5V4Nmoo$-nPkd)BBUL(i_b})WEYQW-<3&*oqHaD5n|`|C3Suydp&0 znJ5G=t|JbdX9z(UZe!7YQD=;}b&z5BuddrnFjg!Xbl|y> z;Yg97iiy-hyPt`8B~RF5%_>N#q;= zjUqY)>8#|hR&dBwF%bUlaL-vbAs;DIJ>v5l)=%H@T}ObTwJt~~KJ zzEObK_=%Y)N5X9DRfE`ek%cI2Aipu|!u@u~fH()jY+GUk_gl0%aatQ0S520(gxg50 zHb@-Kuv2FIKY5QG+*Te>;%rTy>>bN9**1`$e>JxdKNquqX^9X=T5`PcWIxG0R4(1!((+Fu3gwiNxD34YWBu7H%`K zS|K(+O;TZ;JDDrliRl;T=8twKm^O>0i8B(F(vm0FXUH>7n>;_m8m4)&SX#+siJZkm j=?BFi_hgwo0mkW*b@Oac%vfGXoEacD$gv19aWDV?1-XN7 delta 818 zcmeBw$++)1BQw{w=Np+Vn3#U@Otxh*WPHBaz&ML#@=dlp#>&ZtE-8}>Evy+0CpYN$ zFqxZ7cI0T}Tf!~G$HnYlS|Y@rTv9aIP*IJsWAj7TZsy5NJXkdq8f8ol;!|S$Jh_z5 znDGJ7f@YS<=Oz5GS+G!{k#XMSZz3j)jX*P(Fym5JXw(HXZ;=$-ygw><%u`l`n}WNjYBS-q=39izN3ns5|g_!$^8Jpc8Gfll!fM!N{!_C|pO2EuJfgm#lgK(Rf8V)kE zD;#d-(?pzReuxFRlP3;jrehp#Gp8o2Fix7hE7^(h{bqxFTjt4D>5H-X$&n*@a&Czn tlT!EOs7!0HVms!^S8^6%R}2a$?#VSJ{7gzclRxL#fHge88d?yOl>nE{8Danc diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/model/join/test_program b/paddle/fluid/train/custom_trainer/feed/scripts/model/join/test_program index f056e29f9a0bd56332391fd16aee5212ce5e3a20..51a84cf072d40d44de5e1bb2ae7624e853b2d251 100644 GIT binary patch delta 1397 zcmeBeVOr3}#LP9LZ6ot~HpZWmH?#d=JhnM7tcP*44W|MlQ#0e_LjM#_9fjQdyv&mP zqR9uiY#7Za3kLWwSr|-aRB;m);9^fLD9+5u&l6x&72kf*LTT0HCEU9hmjX?(Wt#j! z!jF(4-Z_kCCc6ntX6oSFypg?|akGKq6h>k+ssu59n%pIt&vcIiqA@@%i#UyLj7uh$ zNNs^Ra+f-BjuenbcH|?%!2@z&hzha;cM#SDa-5we+;Ijv#5wMkF0$i*AxMNqa0tp7 zBRdcng2ZS9Ig-Ny?npmZ;vBie2F;N~Xaqa*g(I3HiO~phoDIiV0ob~6!`SuCQ^9M~5@&}U!=*2JSZkQj|12d1UKLvc+ZLA$^? znkf^_kwj<&JJKx=&5^`tbYomO*`Rn6;~HSGqrxvWXfbgZ)--w$qV^? zn9NNk7iKC=4lq`kJcnC|asK4>+`AZO0X5h%O%@RG!>&Gu@!;ebfys=2H-9t+8vHMN z3L|dCAj1t9pHE&bn$LI{sNowPgTW4AoH==c)E1Z{{;1<|gu6VdBXBB)Ibxa$+!1)y zssJ6)tqFHTtqvYX80n!p0;gh_BN~k%j&Nbd9=xznD6@b&Aj2Au17vMc9e`6Y%mF!0 z@KC_378DAJ?r=x!4Z-6G4j)uU;8YBAM0gF z;aZpjoD$#;z^fMI0P|FMC}?KjFc;*Adzna%c!VdrfpUayKHLE~4TYqId6Sh&HZd*) zW=j>O$v?~TaD~Fr$>%C2Ft%*oXv@w#IjshVI!FM#pR8C{z<3LoBkwXz&Tqt{R+&YJ HiGu+E&&!Bt diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/model/update/main_program b/paddle/fluid/train/custom_trainer/feed/scripts/model/update/main_program index ab8290d6940dc12a2fb052df286f44a4abf8cb10..42e13b415b99886634974a26c91644f7c604e2a4 100644 GIT binary patch delta 2152 zcmbW3Ur1A77{>j+GqRnLVt*VF(N-ctQYkr$iVW&plz)deLCvC|GHWX$N-3;dgk8A# zAhwBg0&9rvgnlEGV01A85o9^&Dx?c3=pwoh@}i5*&SB?F7@TiiAD(l5Jn#EF?}<$d zEFlQuRAO4_66tF@7BVgjh{H5i%0By^6C_7x5O=oGCj_tJm+iH#8~&Tu?)Y!x(fOmK z5hs*pdguT;CVR-@a5?CpU6V0a#R{>|+?qIvc3&A;g|yXAzA<@T609Y*lHG6Ys7ble zxqUt5gK92Hq<5N_zjqaZS-D5YT%&kc-O7s^Ot?{1laI>K+F&Ku424{4qJG?01nT!X z9rX`IOM{gy>L3KwRV;ZDd1GgIH_k^HIAT(Ujuk=qzR93e#yKeU*&iQqBX!C!lqE-r z)vD=kHk~#(FEkgy`Lxa841tex%8p3T1$2g~VkGGW-aZRh>`fMR3ER$wXxNBSA3^+_ zl`t2lzv%J>$PbqGwQ$6VwO^_bsHYC;?q6n{)pxO#D?e$$2OT}L>VtY!u@@e{lCNrH z-GM4w0hPqI+^sM49f`!S&^yM)U|R{tv~QV?hTG< zWu-=oXBi|CL1<{%C`PWu^U}v6!b46R9$Cvpl6TK#?1&nKJh75!#DV=$C(gY5WMFdT zSi{UJzfKsK>cQY`4jIWwgOsPHvR-~sOfR`AF$>AACdx_9NR5!Mfn{8r(+N2{KTCK& zX%ceX7md)7T1PkozH=tSHm?(M98Yc1O2&zUi{_-cF145Ti%iLE$~Tekzu>xUGu>G7 E4<&&>;s5{u delta 1890 zcma)-Ur19?9LGE7j@qu(%!+AZZg)Ny6{|2NE+ip_gq1H5g0h!A6iucN1!>S9LI#D+ zec31{Oo$RJq;;$ZgA`;XJt#hm49b@tvWLJP!h*o=cJJ=~bnj{J-}5`4^ZR{&-@~Sb ziKHNiiDXjniFDM0j-=>!AloEY#xq%2{#^yLS6=yV^sJqOGojx|`7N z36ObISV1?Y_G-O6sIlU52+w_0RvOK;%Zx3k0~&} zsBz(3TOv;!xZp18N(Sga3kPV`lLu;SDFevWrU4li&H>>>%z<`q2@z*bOQ-WRy${Qv zv3DvoUfx{EIBe%%kVjejvh|Re=$jxw-XYZ$CPVDj;cWtXdiwNrd9(b$K3^aCB-{2g zg?NLfXVreIK##kz96X5Tf%(FP$rfbKF0N6opr-egENGT1d@Mb^mmTSEFmX;x?8DV2 z-u;q5q%n*P#>;w6MtvWzZ?2TpED6@wPWs!zx`sqj&K#of-Hm7CfHzplM5N&g)W>WX z4Zl_5M&2u~aTJsd3#*S=N%86$`Z5Yl4k zoF*b7skOqXB^EeS3%=KwxL=CuBUjpn$tBfC|NFKSxStm0O7AH05%*`jY^tK>Eq?(h C^MVWj diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/model/update/model.yaml b/paddle/fluid/train/custom_trainer/feed/scripts/model/update/model.yaml index 9bf93e56..a599d5f9 100644 --- a/paddle/fluid/train/custom_trainer/feed/scripts/model/update/model.yaml +++ b/paddle/fluid/train/custom_trainer/feed/scripts/model/update/model.yaml @@ -1,3 +1,4 @@ +aa_Attention: Do Not Modify This File Manually, Unless You Really Know It input_accessor: - class: AbacusSparseUpdateAccessor input: @@ -79,6 +80,10 @@ labels: - name: label_ctr shape: [-1, 1] loss: loss_ctr +monitor: +- {class: AucMonitor, compute_interval: 3600, name: epoch_auc, target: ctr.tmp_2, + target_idx: 0} +- {class: AucMonitor, compute_interval: 86400, name: day_auc, target: ctr.tmp_2, target_idx: 0} outputs: - name: ctr.tmp_2 shape: [-1, 1] diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/model/update/startup_program b/paddle/fluid/train/custom_trainer/feed/scripts/model/update/startup_program index ad56050377a0dce6412cfdab650483f88ab5f43a..2b010666efdbb4bfd997eb8ae32963bdcfc31f07 100644 GIT binary patch delta 733 zcmbO{g>m{+MrN-5sT-Li7@695C&w}xGJWCRY$#&HxLHBnoO$w3)&izx#>oe@QaE)K za`W>tOY(~*JDA%rnomyD_F=Lxn7m%QX!0p`e#VWHZ?PLQPTjoFrJH&3Om4#3+$Q%M zDosw{Rbp!3o!r7}#Pk+!aS-!l8zDb}7B@1kp8Q+bgs~53=~Cv&)^E6;ps)`azjQOLwUvTe^UmppzRJ*Gx9lfm_IJK%9lHOpUyguNfj+7RWrg z*Nm|4^vMA(Jd^D#_!-wu_OpOkyo`BrpBdr6fdub4TNVCBULk%iX8+O>A&#`&Zwwn~%#**Hxu(za$a zocvM3hsoSz@ z#z#O)T39B36Zgk&i8bSb$uc4)jLkp`zA)ofn=$!@D%kMTl5oS-RfsU$R{>)9GUmw| zDt<&*@JAJHL4*N83l>hU(}7zMX@JLqZl-TMll6=shF@mE?GjMfD^5P?!Xv<_#LdN; zQc_uvD!?GYst7 NTe9B+uO$Uu>Ht?a+E@Sp diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/model/update/test_program b/paddle/fluid/train/custom_trainer/feed/scripts/model/update/test_program index 5e6ef75f3b3f7bb164aae179dd5951deecc3b04a..971e83f091ccc7a11aeacf9d2744ce36dd6ec31b 100644 GIT binary patch delta 1013 zcmcb!i*eB&MrN*Adp0tsu`n*3oW-)4artIB)?Oy2X2!_}15-G46ms+PGE4G{Ci8RH zFq%(J4Dw;JFqphPD2MUfWOmNUOkJFt%y2Jq30#5~WdvaoJ=`;VnQ%z7rQzFul z%hk{v`ACI$N50iYIP#?~368vJ0CHrXA(4(OH$`*gCS&3qxz`He$elJMIC7;u$dPdl zL^{&l1K59G&vx!fM8P2VZ1b1CU^qVM0noW-)4an9zChIUMoW7z!}D<>B^r%b-@Y|UsmSuog# z$=qZzqpZ^8ZWk}c!;^(LCo}!$*vzQh&A9nxXf@;H21_a2x`G&APEO{_XSxd25g?z# zI60Qx54#<1jI$?432%Y9#aE1gTbL!VxCN&!kXu4zk=?S35w|jx)+*T6r6FoWx-@Q|4odGH(&Ihf;T*lPd*bo pfvJrXmR4Wmi0vT8kCPQ63z+V}(`X>$>=mMBE-bO002E-7N7tC diff --git a/paddle/fluid/train/custom_trainer/feed/scripts/update.py b/paddle/fluid/train/custom_trainer/feed/scripts/update.py index 63525348..35aacda0 100644 --- a/paddle/fluid/train/custom_trainer/feed/scripts/update.py +++ b/paddle/fluid/train/custom_trainer/feed/scripts/update.py @@ -38,8 +38,12 @@ def inference(): { "class": "DenseInputAccessor", "input": "vars", "table_id": 3, "need_gradient": True, "async_pull": True}, { "class": "LabelInputAccessor", "input": "labels"} ] + monitors = [ + { "name": "epoch_auc", "class": "AucMonitor", "target": ctr_output, "compute_interval": 600 }, + { "name": "day_auc", "class": "AucMonitor", "target": ctr_output, "compute_interval": 86400 } + ] - return accessors, [sparse_cvm], [cvm_input], [ctr_output] + return accessors, [sparse_cvm], [cvm_input], [ctr_output], monitors def loss_function(ctr_output): """ -- GitLab