vissl.meters package

vissl.meters.accuracy_list_meter

class vissl.meters.accuracy_list_meter.AccuracyListMeter(num_meters: int, topk_values: List[int], meter_names: List[str])[source]

Bases: classy_vision.meters.classy_meter.ClassyMeter

Meter to calculate top-k accuracy for single label image classification task.

Supports Single target and multiple output. A list of accuracy meters is constructed and each output has a meter associated.

Parameters
  • num_meters – number of meters and hence we have same number of outputs

  • topk_values – list of int k values. Example: [1, 5]

  • meter_names – list of str indicating the name of meter. Usually corresponds to the output layer name.

classmethod from_config(meters_config: vissl.utils.hydra_config.AttrDict)[source]

Get the AccuracyListMeter instance from the user defined config

property name

Name of the meter

property value

Value of the meter globally synced. For each output, all the top-k values are returned. If there are several meters attached to the same layer name, a list of top-k values will be returned for that layer name meter.

sync_state()[source]

Globally syncing the state of each meter across all the trainers.

get_classy_state()[source]

Returns the states of each meter

set_classy_state(state)[source]

Set the state of each meter

update(model_output: Union[torch.Tensor, List[torch.Tensor]], target: torch.Tensor)[source]

Updates the value of the meter for the given model output list and targets.

Parameters
  • model_output – list of tensors of shape (B, C) where each value is either logit or class probability.

  • target – tensor of shape (B).

NOTE: For binary classification, C=2.

reset()[source]

Reset all the meters

validate(model_output_shape, target_shape)[source]

Not implemented

vissl.meters.mean_ap_meter

class vissl.meters.mean_ap_meter.MeanAPMeter(meters_config: vissl.utils.hydra_config.AttrDict)[source]

Bases: classy_vision.meters.classy_meter.ClassyMeter

Meter to calculate mean AP metric for multi-label image classification task.

Parameters

meters_config (AttrDict) – config containing the meter settings

meters_config should specify the num_classes

classmethod from_config(meters_config: vissl.utils.hydra_config.AttrDict)[source]

Get the AccuracyListMeter instance from the user defined config

property name

Name of the meter

property value

Value of the meter globally synced. mean AP and AP for each class is returned

gather_scores(scores: torch.Tensor)[source]

Do a gather over all embeddings, so we can compute the loss. Final shape is like: (batch_size * num_gpus) x embedding_dim

gather_targets(targets: torch.Tensor)[source]

Do a gather over all embeddings, so we can compute the loss. Final shape is like: (batch_size * num_gpus) x embedding_dim

sync_state()[source]

Globally syncing the state of each meter across all the trainers. We gather scores, targets, total sampled

reset()[source]

Reset the meter

set_classy_state(state)[source]

Set the state of meter

get_classy_state()[source]

Returns the states of meter

verify_target(target)[source]

Verify that the target contains {-1, 0, 1} values only

update(model_output, target)[source]

Update the scores and targets

validate(model_output, target)[source]

Validate that the input to meter is valid

vissl.meters.mean_ap_list_meter

class vissl.meters.mean_ap_list_meter.MeanAPListMeter(meters_config: vissl.utils.hydra_config.AttrDict)[source]

Bases: classy_vision.meters.classy_meter.ClassyMeter

Meter to calculate mean AP metric for multi-label image classification task on multiple output single target.

Supports Single target and multiple output. A list of mean AP meters is constructed and each output has a meter associated.

Parameters

meters_config (AttrDict) – config containing the meter settings

meters_config should specify the num_meters and meter_names

classmethod from_config(meters_config: vissl.utils.hydra_config.AttrDict)[source]

Get the AccuracyListMeter instance from the user defined config

property name

Name of the meter

property value

Value of the meter globally synced. For each output, mean AP and AP for each class is returned.

sync_state()[source]

Globally syncing the state of each meter across all the trainers.

get_classy_state()[source]

Returns the states of each meter

set_classy_state(state)[source]

Set the state of each meter

update(model_output: Union[torch.Tensor, List[torch.Tensor]], target: torch.Tensor)[source]

Updates the value of the meter for the given model output list and targets.

Parameters
  • model_output – list of tensors of shape (B, C) where each value is either logit or class probability.

  • target – tensor of shape (B).

NOTE: For binary classification, C=2.

reset()[source]

Reset all the meters

validate(model_output_shape, target_shape)[source]

Not implemented