コード例 #1
0
ファイル: maxentmodel.cpp プロジェクト: izenecloud/icma
// TODO: test & document this function
void MaxentModel::dump_events(const string& model, bool binary) const {
    if (!m_es || m_es->size() == 0)
        throw runtime_error("empty model, no events to dump");

    if (binary)
        throw runtime_error("binary events file not supported yet");

    display("Dumping events to %s.ev%s", model.c_str() , (binary?".bin":""));
    if (binary) {
        string file = model + ".ev.bin";
        // save_events_bin(f, *m_es);
    } else {
        string file = model + ".ev";
        save_events_txt(file, *m_es);
    }

    // save model
    MaxentModelFile f;
    f.set_pred_map(m_pred_map);
    f.set_outcome_map(m_outcome_map);
    f.set_params(m_params, m_n_theta, m_theta);
    f.save(model, binary);

    if (m_heldout_es->size() > 0) {
        display("Dumping heldout events to %s.heldout.ev%s", model.c_str() , (binary?".bin":""));
        if (binary) {
            string file = model + ".heldout.ev.bin";
            // save_events_bin(f, *m_heldout_es);
        } else {
            string file = model + ".heldout.ev";
            save_events_txt(file, *m_heldout_es);
        }
    }
}
コード例 #2
0
ファイル: maxentmodel.cpp プロジェクト: izenecloud/icma
/**
 * Save a MaxentModel to a file.
 *
 * @param model The name of the model to save.
 * @param binary If true, the file is saved in binary format, which is usually
 * smaller (if compiled with libz) and much faster to load.
 */
void MaxentModel::save(const string& model, bool binary) const {
    if (!m_params)
        throw runtime_error("no model to save (empty model)");
    MaxentModelFile f;
    f.set_pred_map(m_pred_map);
    f.set_outcome_map(m_outcome_map);
    f.set_params(m_params, m_n_theta, m_theta);
    f.save(model, binary);
}
コード例 #3
0
ファイル: maxentmodel.cpp プロジェクト: YPench/CEDT
//S:
void MaxentModel::save_paremeter_on_decrease(const char* filepath){

	if (!m_params)
        throw runtime_error("no model to save (empty model)");
    MaxentModelFile f;
    f.set_pred_map(m_pred_map);
    f.set_outcome_map(m_outcome_map);
    f.set_params(m_params, m_n_theta, m_theta);
    f.save_paremeter_on_decrease(filepath);
}