Skip to content

TST/CLN: Fix warning about "copy construct from a tensor" caused by vak.metrics.distance.functional.character_error_rate #800

@NickleDave

Description

@NickleDave

We get a warning in tests from vak.metrics.distance.functional.character_error_rate, basically because we call torch.tensor

tests/test_eval/test_frame_classification.py: 5 warnings
tests/test_learncurve/test_frame_classification.py: 8 warnings
tests/test_metrics/test_distance/test_functional.py: 6 warnings
tests/test_train/test_frame_classification.py: 4 warnings
  /home/ildefonso/Documents/repos/vocalpy/vak-vocalpy/src/vak/metrics/distance/functional.py:100: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
    return torch.tensor(rate, dtype=torch.float32)

I think the fix here is to do something like torch.FloatTensor instead of calling the torch.tensor constructor -- unless I'm confused the computed distance is a float, or maybe a numpy.float32?
I'm pretty sure we're not constructing from a tensor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions