MCPcopy Create free account
hub / github.com/dmlc/parameter_server / loadTrainingData

Method loadTrainingData

src/learner/bcd.h:32–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 virtual ~BCDScheduler() { }
31
32 void loadTrainingData(const DataConfig& train) {
33 // ask the workers to load the data
34 auto load_time = tic();
35 auto confs = Postmaster::partitionData(train, sys_.yp().num_workers());
36 std::vector<Task> loads(confs.size());
37 for (int i = 0; i < confs.size(); ++i) {
38 auto bcd = loads[i].mutable_bcd();
39 bcd->set_cmd(BCDCall::LOAD_DATA);
40 *bcd->mutable_data() = confs[i];
41 }
42 int hit_cache = 0;
43 port(kWorkerGroup)->submitAndWait(loads, [this, &hit_cache](){
44 LoadDataReturn info; CHECK(info.ParseFromString(exec_.lastRecvReply()));
45 // LL << info.DebugString();
46 g_train_info_ = mergeExampleInfo(g_train_info_, info.example_info());
47 hit_cache += info.hit_cache();
48 });
49 if (hit_cache > 0) {
50 CHECK_EQ(hit_cache, loads.size()) << "clear the local caches";
51 LI << "Hit local caches for the training data";
52 }
53 LI << "Loaded " << g_train_info_.num_ex() << " examples in "
54 << toc(load_time) << " sec";
55
56
57 // preprocess the training data
58 for (int i = 0; i < g_train_info_.slot_size(); ++i) {
59 auto info = g_train_info_.slot(i);
60 CHECK(info.has_id());
61 if (info.id() == 0) continue; // it's the label
62 fea_grp_.push_back(info.id());
63 }
64 auto preprocess_time = tic();
65 Task preprocess;
66 auto prep_bcd = preprocess.mutable_bcd();
67 prep_bcd->set_cmd(BCDCall::PREPROCESS_DATA);
68 for (auto grp : fea_grp_) prep_bcd->add_fea_grp(grp);
69 prep_bcd->set_hit_cache(hit_cache > 0);
70 port(kCompGroup)->submitAndWait(preprocess);
71 LI << "Preprocessing is finished in " << toc(preprocess_time) << " sec";
72 if (bcd_conf_.tail_feature_freq()) {
73 LI << "Features with frequency <= " << bcd_conf_.tail_feature_freq()
74 << " are filtered";
75 }
76 }
77
78 void divideFeatureBlocks() {
79 // partition feature blocks

Callers

nothing calls this directly

Calls 15

ticFunction · 0.85
mergeExampleInfoFunction · 0.85
tocFunction · 0.85
num_workersMethod · 0.80
mutable_bcdMethod · 0.80
submitAndWaitMethod · 0.80
lastRecvReplyMethod · 0.80
hit_cacheMethod · 0.80
num_exMethod · 0.80
slot_sizeMethod · 0.80
add_fea_grpMethod · 0.80
set_hit_cacheMethod · 0.80

Tested by

no test coverage detected