当前位置: 首页>>代码示例>>C++>>正文


C++ AzParam::vLoss方法代码示例

本文整理汇总了C++中AzParam::vLoss方法的典型用法代码示例。如果您正苦于以下问题:C++ AzParam::vLoss方法的具体用法?C++ AzParam::vLoss怎么用?C++ AzParam::vLoss使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AzParam的用法示例。


在下文中一共展示了AzParam::vLoss方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: resetParam

/*--------------------------------------------------------*/
int AzRgforest::resetParam(AzParam &p)
{
    const char *eyec = "AzRgforest::resetParam";

    /*---  for storing data indexes in the trees to disk  ---*/
    /*---  this must be called before adjustTestInterval. ---*/
    p.vStr(kw_temp_for_trees, &s_temp_for_trees);

    /*---  loss function   ---*/
    p.vLoss(kw_loss, &loss_type);

    /*---  weight optimization interval  ---*/
    int lnum_inc_opt = lnum_inc_opt_dflt;
    p.vInt(kw_lnum_inc_opt, &lnum_inc_opt);
    if (lnum_inc_opt <= 0) {
        throw new AzException(AzInputNotValid, eyec, kw_lnum_inc_opt,
                              "must be positive");
    }
    opt_timer.reset(lnum_inc_opt);

    /*---  # of trees to search  ---*/
    p.vInt(kw_s_tree_num, &s_tree_num);
    if (s_tree_num <= 0) {
        throw new AzException(AzInputNotValid, eyec, kw_s_tree_num,
                              "must be positive");
    }

    /*---  when to stop: max #leaf, max #tree  ---*/
    int max_tree_num = -1, max_lnum = max_lnum_dflt;
    p.vInt(kw_max_tree_num, &max_tree_num);
    p.vInt(kw_max_lnum, &max_lnum);
    if (max_tree_num <= 0) {
        if (max_lnum > 0) max_tree_num = MAX(1, max_lnum / 2);
        else {
            AzBytArr s("Specify ");
            s.c(kw_max_lnum);
            s.c(" and/or ");
            s.c(kw_max_tree_num);
            throw new AzException(AzInputMissing, eyec, s.c_str());
        }
    }
    lmax_timer.reset(max_lnum);

    /*---  when to test: test interval  ---*/
    int lnum_inc_test = lnum_inc_test_dflt;
    p.vInt(kw_lnum_inc_test, &lnum_inc_test);
    if (lnum_inc_test <= 0) {
        throw new AzException(AzInputNotValid, eyec, kw_lnum_inc_test,
                              "must be positive");
    }
    lnum_inc_test = adjustTestInterval(lnum_inc_test, lnum_inc_opt);

    test_timer.reset(lnum_inc_test);

    /*---  memory handling  ---*/
    p.vStr(kw_mem_policy, &s_mem_policy);
    if (s_mem_policy.length() <= 0)                     beTight = false;
    else if (s_mem_policy.compare(mp_beTight) == 0)     beTight = true;
    else if (s_mem_policy.compare(mp_not_beTight) == 0) beTight = false;
    else {
        AzBytArr s(kw_mem_policy);
        s.c(" should be either ");
        s.c(mp_beTight);
        s.c(" or ");
        s.c(mp_not_beTight);
        throw new AzException(AzInputNotValid, eyec, s.c_str());
    }

    p.vFloat(kw_f_ratio, &f_ratio);
    if (f_ratio > 1) {
        throw new AzException(AzInputNotValid, kw_f_ratio, "must be between 0 and 1.");
    }
    int random_seed = -1;
    if (f_ratio > 0 && f_ratio < 1) {
        p.vInt(kw_random_seed, &random_seed);
        if (srand > 0) {
            srand(random_seed);
        }
    }

    p.swOn(&doPassiveRoot, kw_doPassiveRoot);

    /*---  for maintenance purposes  ---*/
    p.swOn(&doForceToRefreshAll, kw_doForceToRefreshAll);
    p.swOn(&beVerbose, kw_forest_beVerbose); /* for compatibility */
    p.swOn(&beVerbose, kw_beVerbose);
    p.swOn(&doTime, kw_doTime);

    /*---  display parameters  ---*/
    if (!out.isNull()) {
        AzPrint o(out);
        o.ppBegin("AzRgforest", "Forest-level");
        o.printLoss(kw_loss, loss_type);
        o.printV(kw_max_lnum, max_lnum);
        o.printV(kw_max_tree_num, max_tree_num);
        o.printV(kw_lnum_inc_opt, lnum_inc_opt);
        o.printV(kw_lnum_inc_test, lnum_inc_test);
        o.printV(kw_s_tree_num, s_tree_num);
        o.printSw(kw_doForceToRefreshAll, doForceToRefreshAll);
//.........这里部分代码省略.........
开发者ID:TENorbert,项目名称:HiggsML,代码行数:101,代码来源:AzRgforest.cpp


注:本文中的AzParam::vLoss方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。