Python pytorch_pretrained_bert.optimization.warmup_linear() Examples
The following are 9
code examples of pytorch_pretrained_bert.optimization.warmup_linear().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pytorch_pretrained_bert.optimization
, or try the search function
.
Example #1
Source File: bert_optim.py From gobbli with Apache License 2.0 | 6 votes |
def __init__(self, params, lr, warmup=-1, t_total=-1, schedule='warmup_linear', betas=(0.9, 0.999), eps=1e-6, weight_decay_rate=0.01, max_grad_norm=1.0): if not lr >= 0.0: raise ValueError("Invalid learning rate: {} - should be >= 0.0".format(lr)) if not 0.0 <= warmup < 1.0 and not warmup == -1: raise ValueError("Invalid warmup: {} - should be in [0.0, 1.0[ or -1".format(warmup)) if not 0.0 <= eps: raise ValueError("Invalid epsilon value: {}".format(eps)) if not 0.0 <= betas[0] < 1.0: raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) if not 0.0 <= betas[1] < 1.0: raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) defaults = dict(lr=lr, schedule=schedule, warmup=warmup, t_total=t_total, betas=betas, eps=eps, weight_decay_rate=weight_decay_rate, max_grad_norm=max_grad_norm) super(Adamax, self).__init__(params, defaults)
Example #2
Source File: bert_optim.py From mt-dnn with MIT License | 6 votes |
def __init__(self, params, lr, warmup=-1, t_total=-1, schedule='warmup_linear', betas=(0.9, 0.999), eps=1e-6, weight_decay=0.01, max_grad_norm=1.0): if not lr >= 0.0: raise ValueError("Invalid learning rate: {} - should be >= 0.0".format(lr)) if not 0.0 <= warmup < 1.0 and not warmup == -1: raise ValueError("Invalid warmup: {} - should be in [0.0, 1.0[ or -1".format(warmup)) if not 0.0 <= eps: raise ValueError("Invalid epsilon value: {}".format(eps)) if not 0.0 <= betas[0] < 1.0: raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) if not 0.0 <= betas[1] < 1.0: raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) defaults = dict(lr=lr, schedule=schedule, warmup=warmup, t_total=t_total, betas=betas, eps=eps, weight_decay=weight_decay, max_grad_norm=max_grad_norm) super(Adamax, self).__init__(params, defaults)
Example #3
Source File: bert_optim.py From mt-dnn with MIT License | 6 votes |
def __init__(self, params, lr, warmup=-1, t_total=-1, schedule='warmup_linear', betas=(0.9, 0.999), eps=1e-6, weight_decay=0.001, max_grad_norm=1.0): if not lr >= 0.0: raise ValueError("Invalid learning rate: {} - should be >= 0.0".format(lr)) if not 0.0 <= warmup < 1.0 and not warmup == -1: raise ValueError("Invalid warmup: {} - should be in [0.0, 1.0[ or -1".format(warmup)) if not 0.0 <= eps: raise ValueError("Invalid epsilon value: {}".format(eps)) if not 0.0 <= betas[0] < 1.0: raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) if not 0.0 <= betas[1] < 1.0: raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) defaults = dict(lr=lr, schedule=schedule, warmup=warmup, t_total=t_total, betas=betas, eps=eps, weight_decay=weight_decay, max_grad_norm=max_grad_norm) self.buffer = [[None, None, None] for ind in range(10)] super(RAdam, self).__init__(params, defaults)
Example #4
Source File: bert_optim.py From gobbli with Apache License 2.0 | 5 votes |
def schedule_func(sch): try: f = eval(sch) except: f = warmup_linear return f
Example #5
Source File: NER_BERT_CRF.py From NER-BERT-CRF with MIT License | 5 votes |
def warmup_linear(x, warmup=0.002): if x < warmup: return x/warmup return 1.0 - x
Example #6
Source File: bert_optim.py From MT-DNN with MIT License | 5 votes |
def schedule_func(sch): try: f = eval(sch) except: f = warmup_linear return f
Example #7
Source File: bert_optim.py From MT-DNN with MIT License | 5 votes |
def __init__( self, params, lr, warmup=-1, t_total=-1, schedule="warmup_linear", betas=(0.9, 0.999), eps=1e-6, weight_decay=0.01, max_grad_norm=1.0, ): if not lr >= 0.0: raise ValueError("Invalid learning rate: {} - should be >= 0.0".format(lr)) if not 0.0 <= warmup < 1.0 and not warmup == -1: raise ValueError("Invalid warmup: {} - should be in [0.0, 1.0[ or -1".format(warmup)) if not 0.0 <= eps: raise ValueError("Invalid epsilon value: {}".format(eps)) if not 0.0 <= betas[0] < 1.0: raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) if not 0.0 <= betas[1] < 1.0: raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) defaults = dict( lr=lr, schedule=schedule, warmup=warmup, t_total=t_total, betas=betas, eps=eps, weight_decay=weight_decay, max_grad_norm=max_grad_norm, ) super(Adamax, self).__init__(params, defaults)
Example #8
Source File: bert_optim.py From MT-DNN with MIT License | 5 votes |
def __init__( self, params, lr, warmup=-1, t_total=-1, schedule="warmup_linear", betas=(0.9, 0.999), eps=1e-6, weight_decay=0.001, max_grad_norm=1.0, ): if not lr >= 0.0: raise ValueError("Invalid learning rate: {} - should be >= 0.0".format(lr)) if not 0.0 <= warmup < 1.0 and not warmup == -1: raise ValueError("Invalid warmup: {} - should be in [0.0, 1.0[ or -1".format(warmup)) if not 0.0 <= eps: raise ValueError("Invalid epsilon value: {}".format(eps)) if not 0.0 <= betas[0] < 1.0: raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0])) if not 0.0 <= betas[1] < 1.0: raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1])) defaults = dict( lr=lr, schedule=schedule, warmup=warmup, t_total=t_total, betas=betas, eps=eps, weight_decay=weight_decay, max_grad_norm=max_grad_norm, ) self.buffer = [[None, None, None] for ind in range(10)] super(RAdam, self).__init__(params, defaults)
Example #9
Source File: bert_optim.py From mt-dnn with MIT License | 5 votes |
def schedule_func(sch): try: f = eval(sch) except: f = warmup_linear return f