Skip to content

Sparse losses return nan when there is -inf in the input #9

@erickrf

Description

@erickrf

The sparse loss functions (and their equivalent classes) return nans when there is -inf in the input.

Example:

import torch
import numpy as np
from entmax import entmax15_loss, sparsemax_loss
x = torch.rand(10, 5)
y = torch.randint(0, 4, [10])
x[:, 4] = -np.inf
entmax15_loss(x, y) 
# tensor([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])

sparsemax_loss(x, y)
# tensor([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions