|
|
|
import math |
|
|
|
|
|
class EvaluatedDict: |
|
def __init__(self, d, func): |
|
self.dict = d |
|
self.func = func |
|
|
|
def __getitem__(self, key): |
|
return self.dict[self.func(key)] |
|
|
|
dense_params = EvaluatedDict({False: [0.005, 0.0005, 30, 0.4, 150],True: [None,None,None,None,None],}, lambda x: x == "ImageNet") |
|
def calculate_lr_from_args( epochs, step_lr, start_lr, step_lr_decay): |
|
|
|
n_steps = math.floor((epochs - step_lr) / step_lr) |
|
final_lr = start_lr * step_lr_decay ** n_steps |
|
return final_lr |
|
|
|
ft_params =EvaluatedDict({False: [1e-4, 0.0005, 10, 0.4, 40],True:[[calculate_lr_from_args(150,30,0.005, 0.4), 0.0005, 10, 0.4, 40]]}, lambda x: x == "ImageNet") |
|
|
|
|
|
|