[Python] AttributeError: 'list' object has no attribute 'to' (samples are actually a Tensor)

Discussão em 'Python' iniciado por Stack, Junho 9, 2025.

  1. Stack

    Stack Membro Participativo

    While working on a SSL model, before start training the first epochs I got the following Error:

    samples = samples.to(device, non_blocking=True)
    ^^^^^^^^^^
    AttributeError: 'list' object has no attribute 'to'


    However, after starting debugging I realized that the object is a list of Tensors as depicted in the following image:

    [​IMG]

    As far as I know usually this problem raises when the object is not a Tensor, but at least the list I'm trying to train is a tensor.

    EDIT:

    Python indicates that my samples is a list of Tensors, not just a list. [​IMG]

    Continue reading...

Compartilhe esta Página