Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
None metrics (#4902)
Browse files Browse the repository at this point in the history
* cat or concat

* back to cat

* Only add the metric if it is not None

* lint
  • Loading branch information
mojtaba-komeili authored Dec 5, 2022
1 parent c1c6d91 commit 25df082
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion parlai/core/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def from_mask(
cls, metric_per_token: torch.Tensor, mask: torch.Tensor
) -> List[Metric]:
"""
From token-level metrics, returns an aggregate MyMetric per example in the batch.
From token-level metrics, returns an aggregate MyMetric per example in the
batch.
:param metric_per_token:
a (batchsize x num_tokens) Tensor
Expand Down Expand Up @@ -1097,6 +1098,8 @@ def _consume_user_metrics(self, observation):
# User-reported metrics
if 'metrics' in observation:
for uk, v in observation['metrics'].items():
if v is None:
continue
if uk in ALL_METRICS:
# don't let the user override our metrics
uk = f'USER_{uk}'
Expand Down

0 comments on commit 25df082

Please sign in to comment.