checkpoint_earlystop: Early stopping check

View source: R/checkpoint_earlystop.R

checkpoint_earlystopR Documentation

Early stopping check

Description

Returns list with relative variance over n.steps, absolute.threshold, last value, and logical "stop", if conditions are met and training should stop. The final stop decision is: check.thresh | (check.rthresh & check.rvar) if combine.relative.thresholds = "AND" or check.thresh | (check.rthresh | check.rvar) if combine.relative.thresholds = "OR"

Usage

checkpoint_earlystop(
  x,
  absolute.threshold = NA,
  relative.threshold = NA,
  minimize = TRUE,
  relativeVariance.threshold = NA,
  n.steps = 10,
  combine.relative.thresholds = "AND",
  min.steps = 50,
  na.response = c("stop", "continue"),
  verbose = TRUE
)

Arguments

x

Float, vector: Input - this would normally be the loss at each iteration

absolute.threshold

Float: If set and the last value of x is less than or equal to this (if minimize = TRUE) or greater than or equal to this (if minimize = FALSE), then return stop = TRUE. See output under Value. Default = NA

relative.threshold

Float: If set, checks if the relative change from the first to last value of x exceeds this number. i.e. if set to .9 and minimize = TRUE, if there is a 90 percent drop from x[1] to x[length(x)], then the function returns stop = TRUE. If minimize = FALSE, then checks if there is a 90 percent increase, accordingly.

minimize

Logical: See absolute.threshold. Default = TRUE

relativeVariance.threshold

Float: If relative variance over last n.steps is less than or equal to this, return stop = TRUE. See output under Value

n.steps

Integer; > 1: Calculate relative variance over this many last values of x

combine.relative.thresholds

Character: "AND" or "OR": How to combine the criteria relative.threshold and relativeVariance.threshold. Default = "AND", which means both must be TRUE to stop. The scenario is you might want to check relastiveVariance threshold only after a certain amount of learning has taken place, which you can't predict with min.steps but would rather quantify with relative.threshold.

min.steps

Integer: Do not calculate relativeVariance unless x is at least this length

na.response

Character: "stop" or "continue": what should happen if the last value of x is NA

verbose

Logical: If TRUE, print messages to console

Value

List with the following items:

  • last.value Float: Last value of x

  • relativeVariance Float: relative variance of last n.steps

  • check.thresh Logical: TRUE, if absolute threshold was reached

  • check.rvar Logical: TRUE, if relative variance threshold was reached

  • stop Logical: TRUE, if either criterion was met - absolute threshold or relativeVariance.threshold

Author(s)

E.D. Gennatas


egenn/rtemis documentation built on Oct. 28, 2024, 6:30 a.m.