Skip to content

Accepted dimensionality / shapes #3

@e-pet

Description

@e-pet

Hi Maarten!

I am a little confused by the tensor shapes that are or are not being accepted.

In my training loop, I actually have 1-D shapes for preds / sensitive features / labels.

But that is not accepted:

import torch
import fairret.statistic

preds = torch.tensor([0.1, 0.2, 0.3, 0.4])
sens = torch.tensor([0, 0, 1, 1])
labels = torch.tensor([0, 1, 0, 1])

fairret.statistic.TruePositiveRate()(preds, sens, labels)

This raises an error message because of this assumption.

If I artificially add another dimension this runs without error, but I still cannot compute a loss:

import torch
import fairret.statistic
import fairret.loss

# len(shape) == 2 now
preds = torch.tensor([[0.1, 0.2, 0.3, 0.4]])
sens = torch.tensor([[0, 0, 1, 1]])
labels = torch.tensor([[0, 1, 0, 1]])

# "works"
fairret.statistic.TruePositiveRate()(preds, sens, labels)
# fails with "ValueError: Invalid dimensions (1, 8) for Parameter value." in some low-level cvxpy function
fairret.loss.KLProjectionLoss(fairret.statistic.TruePositiveRate())(preds, sens, labels)

Could you provide any hints as to how this is supposed to be used?

I believe it might also be helpful to catch some of these issues early and provide descriptive error messages / suggestions how to fix them. :-)

Cheers
-- Eike

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