e839626c28d8dc6030ce71f3619e934b36fb6627,catalyst/metrics/functional.py,,process_multiclass_components,#,33
Before Change
"expected 1D or 2D with size 1 in the second dim"
)
if targets.max() != len(torch.unique(targets)) - 1:
if raise_class_labels_mismatch:
raise Exception(
"`targets` maximum does not represent number of classes"
)
// mapping classes
outputs, targets = map_labels_to_classes(outputs, targets)
return outputs, targets
def process_multilabel_components(
After Change
num_classes = max(
outputs.shape[argmax_dim], int(targets.max().detach().item() + 1)
)
outputs = torch.argmax(outputs, dim=argmax_dim)
if num_classes is None:
// as far as we expect the outputs/targets tensors to be int64
// we could find number of classes as max available number
num_classes = max(
int(outputs.max().detach().item() + 1),
int(targets.max().detach().item() + 1),
)
if outputs.dim() == 1:
outputs = outputs.view(-1, 1)
else:
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: Scitator/catalyst
Commit Name: e839626c28d8dc6030ce71f3619e934b36fb6627
Time: 2020-10-23
Author: Balaganskij.NN@phystech.edu
File Name: catalyst/metrics/functional.py
Class Name:
Method Name: process_multiclass_components
Project Name: victoresque/pytorch-template
Commit Name: 6027fdf7aa77c038bf533ebcf7b704b1c79c3bc4
Time: 2018-09-16
Author: sunq0313@gmail.com
File Name: model/metric.py
Class Name:
Method Name: my_metric
Project Name: victoresque/pytorch-template
Commit Name: 6027fdf7aa77c038bf533ebcf7b704b1c79c3bc4
Time: 2018-09-16
Author: sunq0313@gmail.com
File Name: model/metric.py
Class Name:
Method Name: my_metric2