Skip to content

It is recommended to remove the "device" parameter from the code #70

@zhang090210

Description

@zhang090210
class AUCMLoss(torch.nn.Module):
    def __init__(self, 
                 margin=1.0, 
                 imratio=None,
                 version='v1',
                 device=None):
        super(AUCMLoss, self).__init__()
        if not device:
            self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
        else:
            self.device =  device

The lightning framework supports the use of multiple devices, and users who do not use the framework can use the to method to move to the desired device, and the "device" parameter makes the lightning framework use RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!
So I suggest removing the "device" parameter

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