Skip to content

Loss plugin indexes into a scalar #9142

@rfejgin

Description

@rfejgin

Issue description

The loss plugin generates this warning with PyTorch 0.4 :

torch/utils/trainer/plugins/loss.py:8: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim

Here's a link to the offending line:
https://github.com/pytorch/pytorch/blob/master/torch/utils/trainer/plugins/loss.py#L8

It appears that this code was not migrated to PyTorch 0.4 as recommended here:
https://pytorch.org/2018/04/22/0_4_0-migration-guide.html

Proposed Fix

That line should be changed from:
return loss[0]
to
return loss.item()

System Info

This is using PyTorch 0.4.0.

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