'tuple' object has no attribute 'to' in pytorch

Hi @ptrblck , Thank you for the helping.
I try to what you saying and here is the debugging result.

I did “print(type(labels))” in train function and test function.
When I did in train, It worked well. (before and after to() type print ‘torch.Tensor’)

But, in test function, It wasn’t.
Until 59s, It worked well.(Print 13 times like below)
CatDataset print → label type : class ‘str’ (data_path label)->class ‘int’(label)
Test print → labels type : <class ‘torch.Tensor’> → <class ‘torch.Tensor’>

And after 59s, It print like below.
CatDataset print → label type : class ‘str’ (data_path label)->class ‘str’(label)
Test print → labels type : <class ‘Tuple’’>

I’m not sure which point make it to change tuple.

Here is my debug result in test.

data_path label <class 'str'>
label <class 'int'>
...
first labels <class 'torch.Tensor'>
second labels <class 'torch.Tensor'>
tensor([[  5.1988, -10.0191,   5.5972],
        [  5.4772,  -8.9061,   4.4289],
		...
        [  2.7645,  -6.2371,   3.9978]])

...
x 13 times 
...

data_path label <class 'str'>
label <class 'str'>
first labels<class 'torch.Tensor'>
second labels<class 'torch.Tensor'>
tensor([[-2.4606,  4.5739, -2.4098],
        [-1.8784,  4.2095, -2.1987]])
first labels <class 'tuple'>
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-b1da10816353> in <module>()
----> 1 test(model, test_loader, device)

<ipython-input-28-297ea79abffe> in test(model, data_loader, device)
     10             imgs = imgs.to(device)
     11             print("first labels",type(labels))
---> 12             labels =  labels.to(device)       
     13             print("second labels",type(labels))

AttributeError: 'tuple' object has no attribute 'to'