当前使用 pycocotools 2.0 库。
我的 train_loader 是:
train_loader, test_loader = get_train_test_loader('dataset', batch_size=16, num_workers=4)
但是代码的训练行:
for i, data in enumerate(train_loader, 0):
images, targets = data
images = images.to(device)
targets = targets.to(device)
结果出错。变量数据、图像和目标都是类元组
Traceback (most recent call last):
File "train.py", line 40, in <module>
images = images.to(device)
AttributeError: 'tuple' object has no attribute 'to'
我怎样才能正确地将这些发送到 cuda 设备?
编辑:
我可以发送 images[0].to(device) 没问题。剩下的怎么寄?