pycmtensor.scheduler#

PyCMTensor scheduler module

Module Contents#

class pycmtensor.scheduler.Scheduler[source]#

Base class for Scheduler object

Constructor for Scheduler class object

class pycmtensor.scheduler.ConstantLR(lr=0.01)[source]#

Bases: Scheduler

Base class for constant learning rate scheduler

Constructor for ConstantLR class object

Parameters:

lr (float, optional) – learning rate value

property lr[source]#

Returns the learning rate value

property history[source]#

Returns the histroy of the learning rate

_record(step, lr)[source]#

Saves the history of the learning rate and returns the current rate

class pycmtensor.scheduler.StepLR(lr=0.01, factor=0.25, drop_every=10)[source]#

Bases: ConstantLR

Base class for step learning rate scheduler

Constructor for StepLR class object

Parameters:
  • lr (float) – initial learning rate value

  • factor (float, optional) – percentage reduction to the learning rate

  • drop_every (int, optional) – step down the learning rate after every n steps

property factor[source]#

Returns the step factor value

property drop_every[source]#

Returns the step distance value

class pycmtensor.scheduler.PolynomialLR(max_steps, lr=0.01, power=1.0)[source]#

Bases: ConstantLR

Base class for polynomial decay learning rate scheduler

Constructor for PolynomialLR class object

Parameters:
  • lr (float) – initial learning rate value

  • max_steps (int) – the max number of training steps to take

  • power (float, optional) – the exponential factor to decay

property power[source]#

Returns the exponent of the polynomial

property max_steps[source]#

Returns the max steps value

class pycmtensor.scheduler.CyclicLR(lr=0.01, max_lr=0.1, cycle_steps=16, scale_fn=None)[source]#

Bases: ConstantLR

Base class for cyclical learning rate scheduler

Constructor for ConstantLR class object

Parameters:
  • lr (float, optional) – the base learning rate value

  • max_lr (float, optional) – the maximum learning rate value

  • cycle_steps (int, optional) – the number of steps to complete a cycle

  • scale_fn (func, optional) – custom scaling policy defined by a single arg

property max_lr[source]#

Returns the maximum learning rate value

property cycle_steps[source]#

Returns the cycle steps value

scale_fn(k)[source]#

Custom scaling policy

class pycmtensor.scheduler.Triangular2CLR(lr=0.01, max_lr=0.1, cycle_steps=16)[source]#

Bases: CyclicLR

Class object for the Triangular2 Cyclic LR scheduler

Constructor for Triangular2CLR class object

Parameters:
  • lr (float, optional) – the base learning rate value

  • max_lr (float, optional) – the maximum learning rate value

  • cycle_steps (int, optional) – the number of steps to complete a cycle

scale_fn(k)[source]#

Calculates the cycle amplitude scale

class pycmtensor.scheduler.ExpRangeCLR(lr=0.01, max_lr=0.1, cycle_steps=16, gamma=0.5)[source]#

Bases: CyclicLR

Class object for the exponential range Cyclic LR scheduler

Constructor for Triangular2CLR class object

Parameters:
  • lr (float, optional) – the base learning rate value

  • max_lr (float, optional) – the maximum learning rate value

  • cycle_steps (int, optional) – the number of steps to complete a cycle

property gamma[source]#

Returns the gamma value

scale_fn(k)[source]#

Calculates the cycle amplitude scale