Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CollaborativeCoding/load_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def _get_metric(self, key):
raise ValueError(f"Metric {key} not supported")

def __call__(self, y_true, y_pred):
y_true, y_pred = y_true.detach().cpu(), y_pred.detach().cpu()
for key in self.metrics:
self.metrics[key](y_true, y_pred)

Expand Down
3 changes: 0 additions & 3 deletions CollaborativeCoding/metrics/EntropyPred.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,13 @@ def __call__(self, y_true: th.Tensor, y_logits: th.Tensor):
assert y_logits.size(-1) == self.num_classes, (
f"y_logit class length: {y_logits.size(-1)}, expected: {self.num_classes}"
)

y_pred = nn.Softmax(dim=1)(y_logits)
print(f"y_pred: {y_pred}")
entropy_values = entropy(y_pred, axis=1)
entropy_values = th.from_numpy(entropy_values)

# Fix numerical errors for perfect guesses
entropy_values[entropy_values == th.inf] = 0
entropy_values = th.nan_to_num(entropy_values)
print(f"Entropy Values: {entropy_values}")
for sample in entropy_values:
self.stored_entropy_values.append(sample.item())

Expand Down