Loss Functions#

Classes#

class BaseScheduler[source]#

Bases: ABC

Abstract base class for schedulers.

extra_repr()[source]#

Additional string representation of the scheduler.

Returns:
str

Additional string representation of the scheduler

get_step(epoch)[source]#

Returns the current value of the scheduler for the given epoch.

Parameters:
epochint | float

Current epoch

Returns:
float

Current value of the scheduler for the given epoch

abstractmethod step(epoch)[source]#

Steps the scheduler.

Parameters:
epochint | float

Current epoch

class BaseFuncScheduler(max_epochs, *, warmup_epochs=0, final_value=1, initial_value=0)[source]#

Bases: BaseScheduler, ABC

Abstract base class for simple function schedulers.

Attributes:
max_epochsint

Maximum number of epochs

warmupint

Number of warmup epochs

initial_valfloat

Initial value of the scheduler

final_valfloat

Final value of the scheduler

Parameters:
max_epochsint

Maximum number of epochs

warmup_epochsint, Optional

Number of warmup epochs, default = 0

final_valuefloat, Optional

Maximum value of the scheduler, default = 1

initial_valuefloat, Optional

Minimum value of the scheduler, default = 0

extra_repr()[source]#

Additional string representation of the scheduler.

Returns:
str

Additional string representation of the scheduler

class LinearScheduler(max_epochs, *, warmup_epochs=0, final_value=1, initial_value=0)[source]#

Bases: BaseFuncScheduler

Linear scheduler.

Attributes:
max_epochsint

Maximum number of epochs

warmupint

Number of warmup epochs

initial_valfloat

Initial value of the scheduler

final_valfloat

Final value of the scheduler

Parameters:
max_epochsint

Maximum number of epochs

warmup_epochsint, Optional

Number of warmup epochs, default = 0

final_valuefloat, Optional

Maximum value of the scheduler, default = 1

initial_valuefloat, Optional

Minimum value of the scheduler, default = 0

step(epoch)[source]#

Steps the scheduler.

Parameters:
epochint | float

Current epoch

class SigmoidScheduler(max_epochs, *, warmup_epochs=0, final_value=1, initial_value=0, compression=0)[source]#

Bases: BaseFuncScheduler

Sigmoid scheduler.

Attributes:
max_epochsint

Maximum number of epochs

warmupint

Number of warmup epochs

initial_valfloat

Initial value of the scheduler

final_valfloat

Final value of the scheduler

compressionfloat

Compression factor for the sigmoid function, higher values result in a steeper curve

Parameters:
max_epochsint

Maximum number of epochs

warmup_epochsint, Optional

Number of warmup epochs, default = 0

final_valuefloat, Optional

Maximum value of the scheduler, default = 1

initial_valuefloat, Optional

Minimum value of the scheduler, default = 0

compressionfloat, Optional

Compression factor for the tanh function, higher values result in a steeper curve, default = 10

extra_repr()[source]#

Additional string representation of the scheduler.

Returns:
str

Additional string representation of the scheduler

step(epoch)[source]#

Steps the scheduler.

Parameters:
epochint | float

Current epoch

class StepScheduler(warmup, max_steps, step_size, gamma, initial_value=1)[source]#

Bases: BaseScheduler

Step scheduler.

Attributes:
warmupint

Number of warmup epochs

max_stepsint

Maximum number of steps

step_sizeint

Number of epochs between each step

gammafloat

Multiplicative factor of the step

initial_valfloat

Initial value of the scheduler

Parameters:
warmupint

Number of warmup epochs

max_stepsint

Maximum number of steps

step_sizeint

Number of epochs between each step

gammafloat

Multiplicative factor of the step

initial_valuefloat

Initial value of the scheduler, default = 1

extra_repr()[source]#

Additional string representation of the scheduler.

Returns:
str

Additional string representation of the scheduler

step(epoch)[source]#

Steps the scheduler.

Parameters:
epochint | float

Current epoch

class TanhScheduler(max_epochs, *, warmup_epochs=0, final_value=1, initial_value=0, compression=0)[source]#

Bases: SigmoidScheduler

Tanh scheduler.

Attributes:
max_epochsint

Maximum number of epochs

warmupint

Number of warmup epochs

initial_valfloat

Initial value of the scheduler

final_valfloat

Final value of the scheduler

compressionfloat

Compression factor for the tanh function, higher values result in a steeper curve

Parameters:
max_epochsint

Maximum number of epochs

warmup_epochsint, Optional

Number of warmup epochs, default = 0

final_valuefloat, Optional

Maximum value of the scheduler, default = 1

initial_valuefloat, Optional

Minimum value of the scheduler, default = 0

compressionfloat, Optional

Compression factor for the sigmoid function, higher values result in a steeper curve, default = 5

step(epoch)[source]#

Steps the scheduler.

Parameters:
epochint | float

Current epoch