This error occurs because the numpy() method is not available for TensorFlow tensors. To convert a TensorFlow tensor to a NumPy array, you can use the numpy() method of the EagerTensor class. So, you need to replace the line x = x.numpy(x) with x = x.numpy().

The corrected code would be:

def transform(x):
    q = model.predict(x)
    return q.argmax(1), q
x, y = next(iter(train_loader))
x = x.to(device)
y = y.to(device)
x = transform(x)
AttributeError in converted code relative to Ecode6 pseudo labelDEC-keras-DA-master DECpy44 call x = transformx DECpy32 transform x = xnumpyx AttributeError Tensor object

原文地址: http://www.cveoy.top/t/topic/bKgq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录