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

Help please, i’m trying to generate the file.npz but i got this error

File “”, line 146, in run
labels += [np.asarray(y.cpu())]
AttributeError: ‘tuple’ object has no attribute ‘cpu’
0% 0/1 [00:15<?, ?it/s]

  with torch.no_grad():
        pool_val, logits_val = net(x)
        pool += [np.asarray(pool_val.cpu())]
        logits += [np.asarray(F.softmax(logits_val, 1).cpu())]
        labels += [np.asarray(y.cpu())]

What is Y? It’s quite possible that it doesn’t need to be moved onto the CPU in the first place.

yes thank you i got it

I got this error now:

File “/content/drive/.shortcut-targets-by-id/1EDEEgDBcJ3ekzn4l1EeLMvH0obpYsF1y/unetgan/”, line 1159, in to
dist = Distribution(self)
TypeError: expected CPU (got CUDA)

Whatever object you’re operating on there was initialised on the GPU (hence CUDA) and needs to be moved to the CPU.