Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
update doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jan 16, 2020
1 parent 1480a51 commit cfd9db1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/gluonnlp/metric/length_normalized_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,20 @@ def __init__(self, axis=0, name='length-normalized-loss',
output_names=output_names, label_names=label_names,
has_global_stats=True)

# Parameter labels should be a list in the form of [target_sequence,
# target_seqauence_valid_length]
def update(self, labels, preds):
"""Update the length normalized metrics with target label and loss
Update the sum_metrics and sum_insts of metrics with provided arguments.
Parameters:
----------
labels: list
a list of two elements. The first element is the target sentence and
the second element is the valid length of target sentence
preds: list or ndarray.ndarray.NDArray
a list of ndarray.ndarray.NDArray or scalar or a single
ndarray.ndarray.NDArray. It is usually the loss predicted by the model
"""
if not isinstance(labels, list) or len(labels) != 2:
raise ValueError('labels must be a list. Its first element should be'
' target sequence and the second element should be'
Expand Down

0 comments on commit cfd9db1

Please sign in to comment.