optimizer.py
def build_optimizer(config, model, whitelisted_params=None, tune_config=None):
    """
    Build optimizer, set weight decay of normalization to 0 by default.
    """
    skip = {}
    skip_keywords = {}

    if hasattr(model, 'no_weight_decay'):
        skip = model.no_weight_decay()
    if hasattr(model, 'no_weight_decay_keywords'):
        skip_keywords = model.no_weight_decay_keywords()
    parameters = set_weight_decay(model, skip, skip_keywords, whitelisted_params)
    # pdb.set_trace()
    opt_lower = config.TRAIN.OPTIMIZER.NAME.lower()
    optimizer = None

    weight_decay = config.TRAIN.WEIGHT_DECAY
    base_lr = config.TRAIN.BASE_LR
    if tune_config is not None:
        if 'weight_decay' in tune_config:
            weight_decay = tune_config['weight_decay']
        if 'base_lr' in tune_config:
            base_lr = tune_config['base_lr']
    # pdb.set_trace()

    if opt_lower == 'sgd':
        optimizer = optim.SGD(parameters, momentum=config.TRAIN.OPTIMIZER.MOMENTUM, nesterov=True,
                              lr=base_lr, weight_decay=weight_decay)
    elif opt_lower == 'adamw':
        optimizer = optim.AdamW(parameters, eps=config.TRAIN.OPTIMIZER.EPS, betas=config.TRAIN.OPTIMIZER.BETAS,
                                lr=base_lr, weight_decay=weight_decay)

    return optimizer

    Build optimizer, set weight decay of normalization to 0 by default.
    
Build optimizer, set weight decay of normalization to 0 by default.
Build optimizer set weight decay of normalization to 0 by default .
def build_optimizer(config, model, whitelisted_params=None, tune_config=None):
    skip = {}
    skip_keywords = {}
    if hasattr(model, 'no_weight_decay'):
        skip = model.no_weight_decay()
    if hasattr(model, 'no_weight_decay_keywords'):
        skip_keywords = model.no_weight_decay_keywords()
    parameters = set_weight_decay(model, skip, skip_keywords, whitelisted_params)
    opt_lower = config.TRAIN.OPTIMIZER.NAME.lower()
    optimizer = None
    weight_decay = config.TRAIN.WEIGHT_DECAY
    base_lr = config.TRAIN.BASE_LR
    if tune_config is not None:
        if 'weight_decay' in tune_config:
            weight_decay = tune_config['weight_decay']
        if 'base_lr' in tune_config:
            base_lr = tune_config['base_lr']
    if opt_lower == 'sgd':
        optimizer = optim.SGD(parameters, momentum=config.TRAIN.OPTIMIZER.MOMENTUM, nesterov=True,
                              lr=base_lr, weight_decay=weight_decay)
    elif opt_lower == 'adamw':
        optimizer = optim.AdamW(parameters, eps=config.TRAIN.OPTIMIZER.EPS, betas=config.TRAIN.OPTIMIZER.BETAS,
                                lr=base_lr, weight_decay=weight_decay)
    return optimizer
def build_optimizer ( config , model , whitelisted_params = None , tune_config = None ) : skip = { } skip_keywords = { } if hasattr ( model , 'no_weight_decay' ) : skip = model . no_weight_decay ( ) if hasattr ( model , 'no_weight_decay_keywords' ) : skip_keywords = model . no_weight_decay_keywords ( ) parameters = set_weight_decay ( model , skip , skip_keywords , whitelisted_params ) opt_lower = config . TRAIN . OPTIMIZER . NAME . lower ( ) optimizer = None weight_decay = config . TRAIN . WEIGHT_DECAY base_lr = config . TRAIN . BASE_LR if tune_config is not None : if 'weight_decay' in tune_config : weight_decay = tune_config [ 'weight_decay' ] if 'base_lr' in tune_config : base_lr = tune_config [ 'base_lr' ] if opt_lower == 'sgd' : optimizer = optim . SGD ( parameters , momentum = config . TRAIN . OPTIMIZER . MOMENTUM , nesterov = True , lr = base_lr , weight_decay = weight_decay ) elif opt_lower == 'adamw' : optimizer = optim . AdamW ( parameters , eps = config . TRAIN . OPTIMIZER . EPS , betas = config . TRAIN . OPTIMIZER . BETAS , lr = base_lr , weight_decay = weight_decay ) return optimizer
Build optimizer, set weight decay of normalization to 0 by default.
Build optimizer set weight decay of normalization to 0 by default .
"""
    Build optimizer, set weight decay of normalization to 0 by default.
    """ # pdb.set_trace() # pdb.set_trace()
config
model
whitelisted_params
tune_config