![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
Silver_Lyan
这个作者很懒,什么都没留下…
展开
-
把tensor转成int
eg. tensor(2) -> 2tensor(2).item()https://blog.csdn.net/zl535320706/article/details/81175372原创 2020-11-02 12:41:52 · 10019 阅读 · 1 评论 -
AttributeError: ‘list‘ object has no attribute ‘cuda‘
AttributeError: ‘list’ object has no attribute ‘cuda’查看自己的target类型,原为[‘1’,‘0’,‘1’,‘1’]。这种列表试字符串型。而应该修改为torch.tensor类型。才能用于网络计算简单改为:先改为numpy再转换为tensor,搞定!label = torch.from_numpy(np.fromstring(label, dtype=int, sep=’,’))所以需要先把target从str映射成int,再转为tensor原创 2020-10-20 15:36:48 · 5056 阅读 · 2 评论 -
AttributeError: can‘t set attribute
AttributeError: can’t set attribute代码涉及了@property@property用法详解:https://www.liaoxuefeng.com/wiki/1016959663602400/1017502538658208报错原因:https://blog.csdn.net/u012743859/article/details/79423118报错代码块(修正后):class POIDataset(Dataset): """ 生成datast原创 2020-10-15 13:03:50 · 2769 阅读 · 0 评论