monitor module

Monitor

A wrapper class for a neural network model which plots fairness metrics with the forward pass.

class monitor.Monitor(model, metrics_dict, groups)

Attributes:

  • model the PyTorch Model Monitor is being used with
  • metric_names list of the names of the metrics used
  • metric_methods list of functions to evaluate metrics in the same order as metric_names
  • groups list of the groups of data
  • fig Matplotlib Pyplot figure with subplots of the value of each metric over training steps
get_fig()

Get fig attribute

Returns:Matplotlib Pyplot figure with subplots corresponding to each metric
update_fig(step_no, data, data_groups, labels)

Update figure at the end of a foward pass with values of metrics for each group and display the figure Assumes model outputs logits to be fed into softmax activation.

Parameters:

  • step_no number of current training step (e.g. mini-batch number, batch number, epoch number)
  • data validation data as list of inputs to model
  • data_groups the group of each element in data as a 1D array
  • labels labels for each element in data as a 1D array