learning sheduler as torch one

This commit is contained in:
GassiGiuseppe 2025-10-08 16:05:22 +02:00
parent c2e13bc9c6
commit b805dc538e

View File

@ -5,11 +5,13 @@ class Custom_lr():
self.__d_model = d_model self.__d_model = d_model
self.__warmup_step = warmup_step self.__warmup_step = warmup_step
self.__epoch = 0
def get_lr(self,epoch) -> int: def step(self) -> int:
return (self.__d_model ** -0.5) * min(epoch ** -0.5, self.__epoch += 1
epoch * (self.__warmup_step ** -1.5)) return (self.__d_model ** -0.5) * min(self.__epoch ** -0.5,
self.__epoch * (self.__warmup_step ** -1.5))
# OTHER LR # OTHER LR