Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Make some arguments to evaluate() optional, add docstring (#4237)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-gardner committed May 13, 2020
1 parent 5227420 commit 189624d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion allennlp/training/util.py
Expand Up @@ -312,8 +312,23 @@ def get_metrics(


def evaluate(
model: Model, data_loader: DataLoader, cuda_device: int, batch_weight_key: str,
model: Model, data_loader: DataLoader, cuda_device: int = -1, batch_weight_key: str = None,
) -> Dict[str, Any]:
"""
# Parameters
model : `Model`
The model to evaluate
data_loader : `DataLoader`
The `DataLoader` that will iterate over the evaluation data (data loaders already contain
their data).
cuda_device : `int`, optional (default=-1)
The cuda device to use for this evaluation. The model is assumed to already be using this
device; this parameter is only used for moving the input data to the correct device.
batch_weight_key : `str`, optional (default=None)
If given, this is a key in the output dictionary for each batch that specifies how to weight
the loss for that batch. If this is not given, we use a weight of 1 for every batch.
"""
check_for_gpu(cuda_device)
with torch.no_grad():
model.eval()
Expand Down

0 comments on commit 189624d

Please sign in to comment.