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

Method saveModel

src/learner/bcd.h:251–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249 }
250
251 void saveModel(const DataConfig& output) {
252
253 if (output.format() == DataConfig::TEXT) {
254 CHECK(output.file_size());
255 std::string file = output.file(0) + "_" + myNodeID();
256 if (!dirExists(getPath(file))) {
257 createDir(getPath(file));
258 }
259 std::ofstream out(file); CHECK(out.good());
260 for (int grp : fea_grp_) {
261 auto key = model_.key(grp);
262 auto value = model_.value(grp);
263 CHECK_EQ(key.size(), value.size());
264 // TODO use the model_file in msg
265 for (size_t i = 0; i < key.size(); ++i) {
266 double v = value[i];
267 if (v != 0 && !(v != v)) out << key[i] << "\t" << v << "\n";
268 }
269 }
270 LI << myNodeID() << " written the model to " << file;
271 }
272 }
273 KVBufferedVector<Key, V> model_;
274};
275

Callers

nothing calls this directly

Calls 8

dirExistsFunction · 0.85
getPathFunction · 0.85
createDirFunction · 0.85
file_sizeMethod · 0.80
keyMethod · 0.80
formatMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected