jactorch.train.monitor#

Functions

binary_classification_accuracy(pred, label)

Compute the accuracy of binary classification.

binary_classification_accuracy_4(pred, label)

classification_accuracy(pred, label[, name])

Compute the accuracy of N-way classification.

monitor_param_gradrms(model)

Monitor the RMS of the gradients of the parameters of the given model.

monitor_param_gradrms_ratio(model)

Monitor the ratio of the RMS of the gradients of the parameters of the given model.

monitor_param_rms(model)

Monitor the RMS of the parameters of the given model.

monitor_param_saturation(model)

Monitor the saturation of the parameters of the given model.

monitor_rms(_dict, **values)

Monitor the RMS of the given values.

regression_accuracy(pred, label[, name])

Compute the accuracy of regression.

Functions

binary_classification_accuracy(pred, label, name='', saturation=True)[source]#

Compute the accuracy of binary classification.

Parameters:
  • pred (Tensor) – the prediction, of the same shape as label.

  • label (Tensor) – the label, of the same shape as pred.

  • name (str) – the name of this monitor.

  • saturation (bool) – whether to check the saturation of the prediction. Saturation is defined as \(1 - \min(pred, 1 - pred)\)

Returns:

a dict of monitor values.

Return type:

Dict[str, float]

binary_classification_accuracy_4(pred, label, name='')[source]#
Parameters:
Return type:

Dict[str, float]

classification_accuracy(pred, label, name='')[source]#

Compute the accuracy of N-way classification.

Parameters:
  • pred (Tensor) – the prediction, of the same shape as label.

  • label (Tensor) – the label, of the same shape as pred.

  • name (str) – the name of this monitor.

Returns:

a dict of monitor values.

Return type:

Dict[str, float]

monitor_param_gradrms(model)[source]#

Monitor the RMS of the gradients of the parameters of the given model.

Parameters:

model (Module) – the model to monitor.

Returns:

a dict of monitor values.

Return type:

Dict[str, float]

monitor_param_gradrms_ratio(model)[source]#

Monitor the ratio of the RMS of the gradients of the parameters of the given model.

Parameters:

model (Module) – the model to monitor.

Returns:

a dict of monitor values.

Return type:

Dict[str, float]

monitor_param_rms(model)[source]#

Monitor the RMS of the parameters of the given model.

Parameters:

model (Module) – the model to monitor.

Returns:

a dict of monitor values.

Return type:

Dict[str, float]

monitor_param_saturation(model)[source]#

Monitor the saturation of the parameters of the given model.

Parameters:

model (Module) – the model to monitor.

Returns:

a dict of monitor values.

Return type:

Dict[str, float]

monitor_rms(_dict, **values)[source]#

Monitor the RMS of the given values. This function takes either a dict or multiple keyword arguments.

Parameters:
  • _dict (Dict[str, Tensor] | None) – a dict of values.

  • **values (Tensor) – multiple keyword arguments.

Returns:

a dict of monitor values.

Return type:

Dict[str, float]

regression_accuracy(pred, label, name='')[source]#

Compute the accuracy of regression.

Parameters:
  • pred (Tensor) – the prediction, of the same shape as label.

  • label (Tensor) – the label, of the same shape as pred.

  • name (str) – the name of this monitor.

Returns:

a dict of monitor values.

Return type:

Dict[str, float]