python 深度学习 解决遇到的报错问题9

编程入门 行业动态 更新时间:2024-10-10 23:15:27

python 深度学习 解决遇到的<a href=https://www.elefans.com/category/jswz/34/1771188.html style=报错问题9"/>

python 深度学习 解决遇到的报错问题9

本篇继python 深度学习 解决遇到的报错问题8-CSDN博客

目录

一、can only concatenate str (not "int") to str

二、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.

三、module 'd2l.torch' has no attribute 'train_ch3'

四、ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'D:\\my\\python-pycharm\\python-envs\\venv-deep\\Lib\\site-packages\\matplotlib\\_c_internal_utils.cp39-win_amd64.pyd'Check the permissions.

五、ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

六、'gbk' codec can't decode byte 0xaf in position 33: illegal multibyte sequence


一、can only concatenate str (not "int") to str

报错:inputs.fillna(inputs.mean()) 

原因:原因是第2列识别为str,无法进行数值平均运算。

解决方法: 我们在括号加入限制条件,仅在数据类型为数值的列进行平均值插值。

二、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.

报错:

原因:读入的numpy数组里的元素是object类型,无法将这种类型转换成tensor。

解决方法:将numpy数组进行强制类型转换成float类型(或者任何pytorch支持的类型:float64, float32, float16, int64, int32, int16, int8, uint8, and bool)

三、module 'd2l.torch' has no attribute 'train_ch3'

报错:'d2l.torch' has no attribute 'train_ch3'

原因:原因就是它和书上要求的d2l版本不同,书上要求d2l版本为0.17.5

解决方法:先卸载旧的版本,

pip uninstall d2l

再下载新的版本,需要以管理员身份运行下载指令,

pip install d2l==0.17.5 --user

如果没有执行成功,试试去掉“--user”,

pip install d2l==0.17.5 -i  --trusted-host pypi.tuna.tsinghua.edu

 然后,重新执行代码,

OK,问题解决了。

四、ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'D:\\my\\python-pycharm\\python-envs\\venv-deep\\Lib\\site-packages\\matplotlib\\_c_internal_utils.cp39-win_amd64.pyd'
Check the permissions.

报错:安装指定版本的d2l时报错

解决方法:需要加上“--user”,

pip install d2l==0.17.5 --user

但是立马报错了,

解决方法如下。

五、ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

报错:

原因:因为在虚拟环境中找不到用户目录,所以不被允许使用 --user 参数来安装包的。

解决方法:打开自己的虚拟环境下的这个pyvenv.cfg文件,

然后,修改include-system-site-packages = true,

OK,解决了。

六、'gbk' codec can't decode byte 0xaf in position 33: illegal multibyte sequence

报错:

原因:这个是编码问题,在打开文件的时候加上编码指定即可

解决方法:需要修改dl的源码,按住ctrl,鼠标点击进入到这个方法,

继续,按住ctrl,鼠标点击进入到这个方法, 

可以看到,这儿是读取了一个txt文件,在open的时候加上编码encoding=‘UTF-8’,

修改完重启jupyter就好了,然后重新执行代码。

更多推荐

python 深度学习 解决遇到的报错问题9

本文发布于:2023-11-16 17:23:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627375.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   深度   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!