@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时出现了下面的错误:
解决方法
在代码的开头加上下面代码可以解决问题
os.environ[“CUDA_VISIBLE_DEVICES”] = ‘0’