當前位置: 首頁>>代碼示例>>Python>>正文


Python cfg.SOLVER屬性代碼示例

本文整理匯總了Python中detectron.core.config.cfg.SOLVER屬性的典型用法代碼示例。如果您正苦於以下問題:Python cfg.SOLVER屬性的具體用法?Python cfg.SOLVER怎麽用?Python cfg.SOLVER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在detectron.core.config.cfg的用法示例。


在下文中一共展示了cfg.SOLVER屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_lr_at_iter

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def get_lr_at_iter(it):
    """Get the learning rate at iteration it according to the cfg.SOLVER
    settings.
    """
    lr = get_lr_func()(it)
    if it < cfg.SOLVER.WARM_UP_ITERS:
        method = cfg.SOLVER.WARM_UP_METHOD
        if method == 'constant':
            warmup_factor = cfg.SOLVER.WARM_UP_FACTOR
        elif method == 'linear':
            alpha = it / cfg.SOLVER.WARM_UP_ITERS
            warmup_factor = cfg.SOLVER.WARM_UP_FACTOR * (1 - alpha) + alpha
        else:
            raise KeyError('Unknown SOLVER.WARM_UP_METHOD: {}'.format(method))
        lr *= warmup_factor
    return np.float32(lr)


# ---------------------------------------------------------------------------- #
# Learning rate policy functions
# ---------------------------------------------------------------------------- # 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:23,代碼來源:lr_policy.py

示例2: lr_func_steps_with_decay

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def lr_func_steps_with_decay(cur_iter):
    """For cfg.SOLVER.LR_POLICY = 'steps_with_decay'

    Change the learning rate specified iterations based on the formula
    lr = base_lr * gamma ** lr_step_count.

    Example:
    cfg.SOLVER.MAX_ITER: 90
    cfg.SOLVER.STEPS:    [0,    60,    80]
    cfg.SOLVER.BASE_LR:  0.02
    cfg.SOLVER.GAMMA:    0.1
    for cur_iter in [0, 59]   use 0.02 = 0.02 * 0.1 ** 0
                 in [60, 79]  use 0.002 = 0.02 * 0.1 ** 1
                 in [80, inf] use 0.0002 = 0.02 * 0.1 ** 2
    """
    ind = get_step_index(cur_iter)
    return cfg.SOLVER.BASE_LR * cfg.SOLVER.GAMMA ** ind 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:19,代碼來源:lr_policy.py

示例3: lr_func_steps_with_lrs

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def lr_func_steps_with_lrs(cur_iter):
    """For cfg.SOLVER.LR_POLICY = 'steps_with_lrs'

    Change the learning rate to specified values at specified iterations.

    Example:
    cfg.SOLVER.MAX_ITER: 90
    cfg.SOLVER.STEPS:    [0,    60,    80]
    cfg.SOLVER.LRS:      [0.02, 0.002, 0.0002]
    for cur_iter in [0, 59]   use 0.02
                 in [60, 79]  use 0.002
                 in [80, inf] use 0.0002
    """
    ind = get_step_index(cur_iter)
    return cfg.SOLVER.LRS[ind] 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:17,代碼來源:lr_policy.py

示例4: lr_func_step

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def lr_func_step(cur_iter):
    """For cfg.SOLVER.LR_POLICY = 'step'
    """
    return (
        cfg.SOLVER.BASE_LR *
        cfg.SOLVER.GAMMA ** (cur_iter // cfg.SOLVER.STEP_SIZE))


# ---------------------------------------------------------------------------- #
# Helpers
# ---------------------------------------------------------------------------- # 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:13,代碼來源:lr_policy.py

示例5: get_step_index

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def get_step_index(cur_iter):
    """Given an iteration, find which learning rate step we're at."""
    assert cfg.SOLVER.STEPS[0] == 0, 'The first step should always start at 0.'
    steps = cfg.SOLVER.STEPS + [cfg.SOLVER.MAX_ITER]
    for ind, step in enumerate(steps):  # NoQA
        if cur_iter < step:
            break
    return ind - 1 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:10,代碼來源:lr_policy.py

示例6: lr_func_step

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def lr_func_step(cur_iter):
    """For cfg.SOLVER.LR_POLICY = 'step'
    """
    return (
        cfg.SOLVER.BASE_LR *
        cfg.SOLVER.GAMMA ** (cur_iter // cfg.SOLVER.STEP_SIZE)) 
開發者ID:facebookresearch,項目名稱:Detectron,代碼行數:8,代碼來源:lr_policy.py

示例7: lr_func_cosine_decay

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def lr_func_cosine_decay(cur_iter):
    """For cfg.SOLVER.LR_POLICY = 'cosine_decay'
    """
    iter_frac = float(cur_iter) / cfg.SOLVER.MAX_ITER
    cos_frac = 0.5 * (np.cos(np.pi * iter_frac) + 1)
    return cfg.SOLVER.BASE_LR * cos_frac 
開發者ID:facebookresearch,項目名稱:Detectron,代碼行數:8,代碼來源:lr_policy.py

示例8: get_lr_func

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import SOLVER [as 別名]
def get_lr_func():
    policy = 'lr_func_' + cfg.SOLVER.LR_POLICY
    if policy not in globals():
        raise NotImplementedError(
            'Unknown LR policy: {}'.format(cfg.SOLVER.LR_POLICY))
    else:
        return globals()[policy] 
開發者ID:facebookresearch,項目名稱:Detectron,代碼行數:9,代碼來源:lr_policy.py


注:本文中的detectron.core.config.cfg.SOLVER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。