Pytorch error记录
- nn.MSEloss()
(1) RuntimeError: Boolean value of Tensor with more than one value is ambiguous
loss函数使用前必须进行实例化
(2) RuntimeError: Found dtype Double but expected Float
target需要从double转换为float类型
方法:
target.to(torch.float32)
- r2(target, pred)
(1) TypeError: can’t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
先把pred和target转到cpu上,.cpu(); 再从计算图中剥离下来 .detach(), 再转成numpy
pred = pred.cpu().detach().numpy()
-
‘SVR’ object has no attribute ‘predict_proba’
sklearn 没有学好啊
.predict() 是用来回归的,得到的是点值
.predict_proba 明显,是预测的概率值 -
Process finished with exit code -1073740791 (0xC0000409)
原因:cudnn没有装好
解决:https://blog.csdn.net/qq_40418553/article/details/125662221
5._pickle.PicklingError: Can’t pickle <class ‘main.ANN’>: attribute lookup ANN on main failed
torch.save 保存模型时出问题, 把模型定义和训练文件分开写,一个model.py, 一个train.py
6.TypeError: can’t convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.
一种问题是数据shape不一致
我的问题是,在一个ndarray里面存了多个ndarray,在append进list的时候就转成ndarray装进去,
list.append(np.array().astype(np.float64))
存到DataFrame之后取出来用的时候,不要用.to_numpy(), 用,to_list()就好了
dgl error记录
1.AttributeError: ‘NoneType’ object has no attribute ‘is_block’
你的数据中存在空值,请删除他