pytorch笔记

1:TypeError: can’t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
yy=y_pred.numpy()
解决方法:改成yy=y_pred.cuda().data.cpu().numpy()

2:tensor和numpy的转换 a是tensor
解决方法:b=a.numpy()

3:读取nii文件并显示的时候
用到import skimage.io as io
ImportError: cannot import name ‘_validate_lengths’
解决方法:出现上述错误的原因是由于在安装其他库的过程中,numpy库的版本变了,所以导致错误。因此,只需升级一下scikit-image库
pip install -U scikit-image

4:AttributeError: ‘torch.device’ object has no attribute ‘_apply’
解决方法:原因是模型没有实例化,net = model() 写成了 net = model;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值