spacecutter icon indicating copy to clipboard operation
spacecutter copied to clipboard

Docs error?

Open ramondalmau opened this issue 4 years ago • 1 comments

Dear Torch friends

Perhaps I am missing something, but I think the docs of "reduction_" function is not correct. Shall it be?

def _reduction(loss: torch.Tensor, reduction: str) -> torch.Tensor:
    """
    Reduce loss
    Parameters
    ----------
    loss : torch.Tensor, [batch_size, 1]
        Batch losses.
    reduction : str
        Method for reducing the loss. Options include 'elementwise_mean',
        'none', and 'sum'.
    Returns
    -------
    loss : torch.Tensor
        Reduced loss.
    """
    if reduction == 'elementwise_mean':
        return loss.mean()
    elif reduction == 'none':
        return loss
    elif reduction == 'sum':
        return loss.sum()
    else:
        raise ValueError(f'{reduction} is not a valid reduction')

?

ramondalmau avatar Jan 31 '21 08:01 ramondalmau

Yup, you're totally right. I should fix that...

EthanRosenthal avatar Feb 02 '21 00:02 EthanRosenthal