首页 > 其他分享 >RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() inst

RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() inst

时间:2022-11-23 13:33:17浏览次数:61  
标签:Use codes Tensor 代码 centers detach numpy cpu

出错代码:

点击查看代码
dataset_numpy = x[0].cpu().numpy()
centers = centers.cpu().numpy()
codes = codes.cpu().numpy()

修改后代码:

点击查看代码
dataset_numpy = x[0].cpu().detach().numpy()
centers = centers.cpu().detach().numpy()
codes = codes.cpu().detach().numpy()

标签:Use,codes,Tensor,代码,centers,detach,numpy,cpu
From: https://www.cnblogs.com/g932150283/p/16917999.html

相关文章