File size: 542 Bytes
83ae704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Copyright (C) 2024-present Naver Corporation. All rights reserved.
# Licensed under CC BY-NC-SA 4.0 (non-commercial use only).
#
# --------------------------------------------------------
# lr schedules for sparse ga
# --------------------------------------------------------
import numpy as np


def linear_schedule(alpha, lr_base, lr_end=0):
    lr = (1 - alpha) * lr_base + alpha * lr_end
    return lr


def cosine_schedule(alpha, lr_base, lr_end=0):
    lr = lr_end + (lr_base - lr_end) * (1 + np.cos(alpha * np.pi)) / 2
    return lr