Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save model #17

Open
jamborta opened this issue Aug 5, 2016 · 1 comment
Open

save model #17

jamborta opened this issue Aug 5, 2016 · 1 comment

Comments

@jamborta
Copy link

jamborta commented Aug 5, 2016

is it possible to save the learnt vector and matrix somehow?

@CNevd
Copy link

CNevd commented Aug 6, 2016

you can use GetUpdater()->Save(bool save_aux, dmlc::Stream *fo) in such as sgd_learner.cc
and Save(bool save_aux, dmlc::Stream *fo) should be implemented first
eg: (just a draft)

void SGDUpdater::Save(bool save_aux, dmlc::Stream *fo) const {
  int saved = 0;
  for (const auto& it : model_) {
    if (it.second.Empty()) continue;
    int n = param_.V_dim;
        fo->Write(&it.first, sizeof(feaid_t));
    fo->Write(it.second.w, sizeof(real_t));
    if (it.second.V) {
      for (int i = 0; i < n;   i) {
        fo->Write(it.second.V[i], sizeof(real_t));
      }
    }
    if (save_aux) {
      fo->Write(&(it.second.z), sizeof(real_t));
      fo->Write(&(it.second.sqrt_g), sizeof(real_t));
    }
    saved    ;
  }
  LOG(INFO) << "saved " << saved << " kv pairs";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants