ValueError: Cannot assign non-leaf Tensor to parameter ‘weight‘.

@ValueError: Cannot assign non-leaf Tensor to parameter ‘weight’. Model parameters must be created explicitly. To express ‘weight’ as a function of another Tensor, compute the value in the forward() method.

ValueError: Cannot assign non-leaf Tensor to parameter ‘weight’. Model parameters must be created explicitly. To express ‘weight’ as a function of another Tensor, compute the value in the forward() method.

自己的电脑有两张显卡在使用get_map获取MAP时出现了下面的错误:

ValueError: Cannot assign non-leaf Tensor to parameter ‘weight‘._第1张图片

解决方法

在代码的开头加上下面代码可以解决问题
os.environ[“CUDA_VISIBLE_DEVICES”] = ‘0’

你可能感兴趣的:(人工智能,机器学习,深度学习,pycharm)