6027fdf7aa77c038bf533ebcf7b704b1c79c3bc4,model/metric.py,,my_metric,#,4
Before Change
def my_metric(y_input, y_target):
assert len(y_input) == len(y_target)
correct = 0
for y0, y1 in zip(y_input, y_target):
if np.array_equal(y0, y1):
correct += 1
return correct / len(y_input)
def my_metric2(y_input, y_target):
After Change
pred = torch.argmax(output, dim=1)
assert pred.shape[0] == len(target)
correct = 0
correct += torch.sum(pred == target).item()
return correct / len(target)
def my_metric2(output, target, k=3):
pred = torch.topk(output, k, dim=1)[1]
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 4
Instances
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: PIQuIL/QuCumber
Commit Name: 274ec230054107d30bb91de43ec42b7393170928
Time: 2019-07-17
Author: emerali@users.noreply.github.com
File Name: qucumber/utils/training_statistics.py
Class Name:
Method Name: NLL
Project Name: PIQuIL/QuCumber
Commit Name: cfa828f6349317ce50a610cd31bb3dcf5e5ea211
Time: 2019-06-05
Author: emerali@users.noreply.github.com
File Name: qucumber/utils/training_statistics.py
Class Name:
Method Name: fidelity
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
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