コード例 #1
0
 inline void _release() {
   a_tree.free(&t); t_num = 0; 
   s_config.reset(); 
   s_sign.reset(); 
   const_val = 0; 
   org_dim = -1; 
 }
コード例 #2
0
ファイル: AzUtil.hpp プロジェクト: fukatani/rgf_python
 inline void open(const char *fn, ios_base::openmode mode) {
   s_fn.reset(fn); 
   ofs.open(fn, mode); 
   if (ofs.fail()) {
     throw new AzException(AzFileIOError, "AzOfs::open", "Failed to open:", fn); 
   }
 }
コード例 #3
0
ファイル: AzTrTreeFeat.hpp プロジェクト: fukatani/rgf_python
 void reset(const AzTrTreeFeatInfo *inp) {
   if (inp == NULL) return; 
   isRemoved = inp->isRemoved; 
   tx = inp->tx; 
   nx = inp->nx; 
   rule.reset(&inp->rule); 
 }
コード例 #4
0
 inline void reset() {
   a_tree.free(&t); t_num = 0; 
   const_val = 0; 
   org_dim = -1; 
   s_param.reset(); 
   dt_param = ""; 
   temp_files.reset(); 
 }
コード例 #5
0
  void warm_start(const AzTreeEnsemble *inp_ens, 
              const AzDataForTrTree *data, 
              AzParam &param,              
              const AzBytArr *s_temp_prefix, 
              const AzOut &out,           
              int max_t_num, 
              int search_t_num, 
              AzDvect *v_p, /* inout */
              const AzIntArr *inp_ia_tr_dx=NULL)
  {
    const char *eyec = "AzTrTreeEnsemble::warmup"; 
    if (max_t_num < inp_ens->size()) {
      throw new AzException(eyec, "maximum #tree is less than the #tree we already have"); 
    }

    reset(); 
    a_tree.alloc(&t, max_t_num, "AzTrTreeEnsemble::warmup"); 
    t_num = inp_ens->size(); 
    const_val = inp_ens->constant(); 
    org_dim = inp_ens->orgdim(); 
    if (org_dim > 0 && org_dim != data->featNum()) {
      throw new AzException(AzInputError, eyec, "feature dimensionality mismatch"); 
    }

    const AzIntArr *ia_tr_dx = inp_ia_tr_dx; 
    AzIntArr ia_temp; 
    if (ia_tr_dx == NULL) {
      ia_temp.range(0, data->dataNum()); 
      ia_tr_dx = &ia_temp; 
    }
    v_p->reform(data->dataNum()); 
    v_p->add(const_val, ia_tr_dx); 

    T dummy_tree(param); 
    if (dummy_tree.usingInternalNodes()) {
      throw new AzException(AzInputError, eyec, 
                "warm start is not allowed with use of internal nodes"); 
    }
    dummy_tree.printParam(out); 

    temp_files.reset(&dummy_tree, data->dataNum(), s_temp_prefix); 

    s_param.reset(param.c_str());   
    dt_param = s_param.c_str(); 
    AzParam p(dt_param, false); 
 
    int tx; 
    for (tx = 0; tx < t_num; ++tx) {
      t[tx] = new T(p); 
      t[tx]->forStoringDataIndexes(temp_files.point_file()); 
      if (search_t_num > 0 && tx < t_num-search_t_num) {
        t[tx]->quick_warmup(inp_ens->tree(tx), data, v_p, ia_tr_dx); 
      }
      else {
        t[tx]->warmup(inp_ens->tree(tx), data, v_p, ia_tr_dx); 
      }
    }    
  }
コード例 #6
0
ファイル: AzxD.hpp プロジェクト: DeercoderCourse/NLP
  virtual void format(AzBytArr &s, bool do_reset=false) const {
    if (do_reset) s.reset(); 
//    s.c("("); 
    int ix; 
    for (ix = 0; ix < ia_sz.size(); ++ix) {
      if (ix > 0) s.c(" x "); 
      s.cn(ia_sz.get(ix)); 
    }
//    s.c(")"); 
  }  
コード例 #7
0
ファイル: AzTETmain.hpp プロジェクト: NavinManaswi/RGF_Hadoop
 AzTETmain(const AzTETselector *inp_alg_sel,
           AzTET_Eval *inp_eval) : s_model_stem(dflt_model_stem), eval(NULL),
                                   doLog(true), doDump(false), doAppend_eval(false),
                                   doSaveLastModelOnly(false),
                                   xv_doShuffle(false), xv_num(2),
                                   doSparse_features(false), features_digits(10)
 {
   alg_sel = inp_alg_sel;
   eval = inp_eval;
   s_alg_name.reset(alg_sel->dflt_name());
 }
コード例 #8
0
ファイル: AzTools_text.cpp プロジェクト: DeercoderCourse/NLP
/* static */
void AzTools_text::parse_cats(const AzBytArr *s_cat, 
                         AzByte dlm,  /* e.g., | for, e.g., GSPO|M11|M12 */
                         bool do_allow_multicat, bool do_allow_nocat, 
                         const AzDic *dic_cat, AzIntArr *ia_cats, /*output */
                         int &multi_cat, int &no_cat, /* inout */
                         AzBytArr &s_err)
{                         
  s_err.reset(); 
  bool my_do_allow_multi = true; 
  _parse_cats(s_cat, dlm, my_do_allow_multi, dic_cat, ia_cats, multi_cat, no_cat); 
  int num = ia_cats->size(); 
  if (num == 1) return; 
  if (num == 0) {
    if (do_allow_nocat) return; 
    s_err.reset("For single-label classification, a data point without any label is not allowed.  Specify "); 
    s_err << kw_do_allow_nocat << " to allow no-label data points."; 
  }
  else if (num > 1) {
    if (do_allow_multicat) return;  
    s_err.reset("For single-label classification, a data point with multiple labels is not allowed.  Specify "); 
    s_err << kw_do_allow_multi << " to allow multi-label data points."; 
  }
} 
コード例 #9
0
  //! copy nodes only; not split
  void copy_nodes_from(const AzTrTreeEnsemble_ReadOnly *inp) {
    reset(); 
    const_val = inp->constant(); 
    org_dim = inp->orgdim(); 
    t_num = inp->size(); 

    s_param.reset(inp->param_c_str()); 
    dt_param = s_param.c_str(); 
    AzParam p(dt_param, false); 
    a_tree.alloc(&t, t_num, "AzTrTreeEnsemble::copy_nodes_from"); 
    for (int tx = 0; tx < t_num; ++tx) {
      t[tx] = new T(p);
      t[tx]->copy_nodes_from(inp->tree(tx)); 
    }
  }
コード例 #10
0
  inline void cold_start(
                    AzParam &param, 
                    const AzBytArr *s_temp_prefix, /* may be NULL */
                    int data_num, /* to estimate the data size for temp */
                    const AzOut &out, 
                    int tree_num_max, 
                    int inp_org_dim) {
    reset(); 
    T dummy_tree(param); 
    dummy_tree.printParam(out); 
    s_param.reset(param.c_str()); 
    dt_param = s_param.c_str(); 
    alloc(tree_num_max, "AzTrTreeEnsemble::reset"); //@ allocate forest space
    org_dim = inp_org_dim; 

    temp_files.reset(&dummy_tree, data_num, s_temp_prefix); //@ estimate the data size for temp and do something?
  }
コード例 #11
0
 void reset(T *tree, 
            int data_num, 
            const AzBytArr *inp_s_temp_prefix) {
   reset(); 
   if (inp_s_temp_prefix == NULL || inp_s_temp_prefix->length() <= 0) {
     return; 
   }
   s_temp_prefix.reset(inp_s_temp_prefix); 
   unit_size = tree->estimateSizeofDataIndexes(data_num); 
   if (unit_size <= 0) {
     return; 
   }
   if (unit_size > max_size) {
     throw new AzException(AzInputError, "AzTemp_forTrTreeEns::reset", 
                           "Data size is too large."); 
   }
   open_new_file();//@?
 }
コード例 #12
0
ファイル: AzpActivDflt.hpp プロジェクト: DeercoderCourse/NLP
 void setup_no_activation() {
   s_activ_typ.reset("None"); 
   typ = 'N'; 
   trunc = -1; 
 }
コード例 #13
0
 void reset() {
   unit_size = -1; 
   s_temp_prefix.reset();
   pool_file.reset(); 
 }
コード例 #14
0
 inline void reset(const AzTreeRule *inp) {
   ba.reset(); 
   if (inp == NULL) return; 
   ba.reset(&inp->ba); 
 }