Skip to content

Instantly share code, notes, and snippets.

View jyhong0304's full-sized avatar

Jinyung Hong jyhong0304

View GitHub Profile
@kyamagu
kyamagu / binary_classification_utils.py
Created June 15, 2017 13:12
Helper for binary classification training in PyTorch
"""
Use in PyTorch.
"""
def accuracy(output, target):
"""Computes the accuracy for multiple binary predictions"""
pred = output >= 0.5
truth = target >= 0.5
acc = pred.eq(truth).sum() / target.numel()
return acc