示例#1
0
void VarRTM::Load(StrC &net_path, StrC &cor_path, int times) {
  ReadData(net_path, &net, &held_out_net_);
  cor.LoadData(cor_path);

  SpMat all_network;
  ReadData(net_path, &all_network);
  TripleVec vec;
  for (int d = 0;d < all_network.cols(); d++) { 
    SInt observed;
    for (SpMatInIt it(all_network, d); it; ++it) {
      int row = it.row();
      observed.insert(row);
    }
    int observed_size = observed.size();
    for (int i = 0;i < observed_size * times; ++i) {
      int k = Random(all_network.rows());
      if(observed.find(k) == observed.end()) {
        vec.push_back(Triple(k, d, -1));
        observed.insert(k);
      }
    }
  }
  for (int d = 0;d < held_out_net_.cols(); d++) {
    for (SpMatInIt it(held_out_net_, d); it; ++it) {
      vec.push_back(Triple(it.row(), d, 1));
    }
  }
  held_out_net_.setFromTriplets(vec.begin(), vec.end());

  LOG(INFO) << cor_path;
  LOG(INFO) << cor.Len();
  LOG(INFO) << net.size();
  LOG(INFO) << held_out_net_.size(); 
}