int main(int argc, char** argv) { gflags::SetUsageMessage("Usage : ./warplda [ flags... ]"); gflags::ParseCommandLineFlags(&argc, &argv, true); if ((FLAGS_inference || FLAGS_estimate) == false) FLAGS_estimate = true; if (!FLAGS_z.empty()) FLAGS_dumpz = true; SetIfEmpty(FLAGS_bin, FLAGS_prefix + ".bin"); SetIfEmpty(FLAGS_model, FLAGS_prefix + ".model"); SetIfEmpty(FLAGS_info, FLAGS_prefix + ".info"); SetIfEmpty(FLAGS_vocab, FLAGS_prefix + ".vocab"); SetIfEmpty(FLAGS_topics, FLAGS_prefix + ".topics"); LDA *lda = new WarpLDA<1>(); lda->loadBinary(FLAGS_bin); if (FLAGS_estimate) { lda->estimate(FLAGS_k, FLAGS_alpha / FLAGS_k, FLAGS_beta, FLAGS_niter, FLAGS_perplexity); if (FLAGS_dumpmodel) { std::cout << "Dump model " << FLAGS_model << std::endl; lda->storeModel(FLAGS_model); } if (FLAGS_writeinfo) { std::cout << "Write Info " << FLAGS_info << " ntop " << FLAGS_ntop << std::endl; lda->writeInfo(FLAGS_vocab, FLAGS_info, FLAGS_ntop); } if (FLAGS_dumpz) { SetIfEmpty(FLAGS_z, FLAGS_prefix + ".z.estimate"); std::cout << "Dump Z " << FLAGS_z << std::endl; lda->storeZ(FLAGS_z); } } else if(FLAGS_inference) { lda->loadModel(FLAGS_model); lda->inference(FLAGS_niter, FLAGS_perplexity); if (FLAGS_dumpz) { SetIfEmpty(FLAGS_z, FLAGS_prefix + ".z.inference"); std::cout << "Dump Z " << FLAGS_z << std::endl; lda->storeZ(FLAGS_z); } } return 0; }