homura.metrics package

Submodules

homura.metrics.commons module

homura.metrics.commons.accuracy(input, target, top_k=1)[source]
Parameters
  • input (torch.Tensor) –

  • target (torch.Tensor) –

  • top_k (int) –

Return type

torch.Tensor

homura.metrics.commons.classwise_accuracy(input, target)[source]

Calculate class wise accuracy

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

class wise accuracy in float tensor of C

Return type

torch.Tensor

homura.metrics.commons.confusion_matrix(input, target)[source]

Calculate confusion matrix

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

confusion matrix in long tensor of CxC

Return type

torch.Tensor

homura.metrics.commons.f1_score(input, target)[source]

Calculate f1 score

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

f1 score in float tensor of C

Return type

torch.Tensor

homura.metrics.commons.false_negative(input, target)[source]

Calculate false negative :param input: output of network, expected to be BxCx(OPTIONAL DIMENSIONS) :param target: target, expected to be Bx(OPTIONAL DIMENSIONS) :return: false negative in float tensor of C

Parameters
  • input (torch.Tensor) –

  • target (torch.Tensor) –

Return type

torch.Tensor

homura.metrics.commons.false_positive(input, target)[source]

Calculate false positive

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

false positive in float tensor of C

Return type

torch.Tensor

homura.metrics.commons.precision(input, target)[source]

Calculate precision

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

precision in float tensor of C

Return type

torch.Tensor

homura.metrics.commons.recall(input, target)[source]

Calculate recall

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

recall in float tensor of C

Return type

torch.Tensor

homura.metrics.commons.specificity(input, target)[source]

Calculate specificity

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

specificity in float tensor of C

Return type

torch.Tensor

homura.metrics.commons.true_negative(input, target)[source]

Calculate true negative

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

true negative in float tensor of C

Return type

torch.Tensor

homura.metrics.commons.true_positive(input, target)[source]

Calculate true positive

Parameters
  • input (torch.Tensor) – output of network, expected to be BxCx(OPTIONAL DIMENSIONS)

  • target (torch.Tensor) – target, expected to be Bx(OPTIONAL DIMENSIONS)

Returns

true positive in float tensor of C

Return type

torch.Tensor

homura.metrics.generative module

Metrics for generated images

homura.metrics.segmentation module

homura.metrics.segmentation.binary_as_multiclass(input, threshold)[source]

Convert Bx1xHxW outputs to BxCxHxW.

Parameters
  • input (torch.Tensor) –

  • threshold (float) –

Returns

Return type

torch.Tensor

homura.metrics.segmentation.classwise_iou(input, target)[source]

Class-wise IoU

Parameters
  • input (torch.Tensor) – logits (BxCxHxW)

  • target (torch.Tensor) – target in LongTensor (BxHxW)

Returns

Return type

torch.Tensor

homura.metrics.segmentation.mean_iou(input, target)[source]

Mean IoU

Parameters
  • input (torch.Tensor) – logits (BxCxHxW)

  • target (torch.Tensor) – target in LongTensor (BxHxW)

Returns

Return type

torch.Tensor

homura.metrics.segmentation.pixel_accuracy(input, target)[source]

Pixel accuracy

Parameters
  • input (torch.Tensor) – logits (BxCxHxW)

  • target (torch.Tensor) – target in LongTensor (BxHxW)

Returns

Return type

torch.Tensor

Module contents