MCPcopy Create free account
hub / github.com/YeWR/EfficientZero / LinearSchedule

Class LinearSchedule

core/utils.py:14–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13
14class LinearSchedule(object):
15 def __init__(self, schedule_timesteps, final_p, initial_p=1.0):
16 """Linear interpolation between initial_p and final_p over
17 schedule_timesteps. After this many timesteps pass final_p is
18 returned.
19 Parameters
20 ----------
21 schedule_timesteps: int
22 Number of timesteps for which to linearly anneal initial_p
23 to final_p
24 initial_p: float
25 initial output value
26 final_p: float
27 final output value
28 """
29 self.schedule_timesteps = schedule_timesteps
30 self.final_p = final_p
31 self.initial_p = initial_p
32
33 def value(self, t):
34 """See Schedule.value"""
35 fraction = min(float(t) / self.schedule_timesteps, 1.0)
36 return self.initial_p + fraction * (self.final_p - self.initial_p)
37
38
39class TimeLimit(gym.Wrapper):

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected