Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ignite/metrics/binary_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class BinaryAccuracy(Metric):
Calculates the binary accuracy.

`update` must receive output of the form (y_pred, y).
`y_pred` must be in the following shape (batch_size, ...)
`y_pred` must be in the following shape (batch_size, ...) and it's
elements must be between 0 and 1.
`y` must be in the following shape (batch_size, ...)
"""
def reset(self):
Expand All @@ -20,7 +21,7 @@ def reset(self):

def update(self, output):
y_pred, y = output
correct = torch.eq(torch.round(y_pred).type(torch.LongTensor), y).view(-1)
correct = torch.eq(torch.round(y_pred).type(y.type()), y).view(-1)
self._num_correct += torch.sum(correct)
self._num_examples += correct.shape[0]

Expand Down