def _init_optimizer(self):
    group_weight = []
    group_bias = []
    for (name, param) in self.model.named_parameters():
        if ('bias' in name):
            group_bias.append(param)
        else:
            group_weight.append(param)
    assert (len(list(self.model.parameters())) == (len(group_weight) + len(group_bias)))
    optim_cls = getattr(torch.optim, self.optimizer_type)
    if (self.optimizer_type == 'Adam'):
        optim_kwargs = {'lr': self.learning_rate, 'weight_decay': self.weight_decay}
    else:
        optim_kwargs = {'lr': self.learning_rate, 'momentum': self.momentum, 'weight_decay': self.weight_decay}
    optim_kwargs.update((self.optimizer_kwargs or {}))
    optimizer = optim_cls([{'params': group_weight}, {'params': group_bias, 'weight_decay': (0 if self.no_bias_decay else self.weight_decay)}], **optim_kwargs)
    return optimizer
def _init_optimizer(self):
    group_weight = []
    group_bias = []
    for (name, param) in self.model.named_parameters():
        if ('bias' in name):
            group_bias.append(param)
        else:
            group_weight.append(param)
    assert (len(list(self.model.parameters())) == (len(group_weight) + len(group_bias)))
    optim_cls = getattr(torch.optim, self.optimizer_type)
    if (self.optimizer_type == 'Adam'):
        optim_kwargs = {'lr': self.learning_rate, 'weight_decay': self.weight_decay}
    else:
        optim_kwargs = {'lr': self.learning_rate, 'momentum': self.momentum, 'weight_decay': self.weight_decay}
    optim_kwargs.update((self.optimizer_kwargs or {}))
    optimizer = optim_cls([{'params': group_weight}, {'params': group_bias, 'weight_decay': (0 if self.no_bias_decay else self.weight_decay)}], **optim_kwargs)
    return optimizer