k1lib.schedule module

This module allows you to make and combine a bunch of schedules, and setup the optimizer so that it changes hyperparameter values based on the schedule. Highly recommend you check out the tutorials section on this.

class k1lib.schedule.Fn(f: Callable[[float], float], param: Optional[str] = None)[source]

Bases: object

__init__(f: Callable[[float], float], param: Optional[str] = None)[source]

Creates a new schedule based on some custom function.

Parameters
  • f – domain should always in [0, 1]

  • param – (optional) Parameter to schedule (e.g “lr”) if using ParamScheduler

property value
iter(n: int)[source]

Returns an n-step iterator evenly divided in range [0, 1]. Example:

s = schedule.Fn(lambda x: x+2)
list(s.iter(6)) # returns [2.0, 2.2, 2.4, 2.6, 2.8, 3.0]
modifyOutput(f: Callable[[float], float])k1lib.schedule.Fn[source]

Returns a new Fn that has its output modified. Example:

s = Fn(lambda x: x+2)
s.modifyOutput(lambda x: x**2) # now s's function is (x+2)**2
k1lib.schedule.linear(low, high, param: Optional[str] = None)[source]

Sharply goes from low to high

k1lib.schedule.smooth(low, high, param: Optional[str] = None)[source]

Smoothly goes from low to high

k1lib.schedule.hump(low, high, param: Optional[str] = None)[source]

Smoothly rises up (30%), then down (70%)

k1lib.schedule.exp(low, high, param: Optional[str] = None)[source]

Rises/drops quickly, then rate of change gets smaller and smaller

class k1lib.schedule.ParamScheduler(css: str, *schedules: List[k1lib.schedule.Fn])[source]

Bases: k1lib.callbacks.callbacks.Callback

Schedules a param in parts of the network.

Parameters
  • css – the selected parts of the network to schedule

  • schedules – (obvious)

startBatch()[source]
startRun()

Schedules a param in parts of the network.

Parameters
  • css – the selected parts of the network to schedule

  • schedules – (obvious)