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

目录

一、AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0.

二、ImportError: cannot import name 'logsumexp'

三、FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'

四、ImportError: numpy.core.multiarray failed to import

五、KeyError: (1204, 1203, 693, 690, 1128, 2306, 2301, 5238, 2304, 2307, 2310, 2949, 2912, 2911, 2709, 2708, 2823, 2097, 2095, 3052, 3672, 2946, 2093, 2092, 2094, 2945, 3658, 3553, 255, 23)


一、AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0.

报错:

原因: Gensim版本 提升, 弃用了vocab这一接口

解决办法:如果只需要key值,调用index_to_key,如果需要键值对(key-value),调用key_to_index

或者

pip install gensim==3.0

二、ImportError: cannot import name 'logsumexp'

原因: scipy.misc包里面更新后没有logsumexp了,这可能是由于gensim版本过低导致的,

解决办法:升级gensim到比较新的版本

pip install gensim==3.8.3

三、FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'

原因:安装的tensorflow版本和numpy版本不匹配。

解决方法:需要将numpy降版本

四、ImportError: numpy.core.multiarray failed to import

报错:RuntimeError:模块根据API版本0xe编译,但此版本的numpy为0xd ImportError:numpy.core.multiarray无法导入 上述异常是以下异常的直接原因: SystemError:<内置函数__import__>返回带有错误集的结果

原因:numpy的版本较低,所以会提示版本问题

解决方法:升级numpy到比较新的版本

pip install numpy==1.15.0

五、KeyError: (1204, 1203, 693, 690, 1128, 2306, 2301, 5238, 2304, 2307, 2310, 2949, 2912, 2911, 2709, 2708, 2823, 2097, 2095, 3052, 3672, 2946, 2093, 2092, 2094, 2945, 3658, 3553, 255, 23)

原因:关键词错误。这个key表示的意思为字典之中的键,在使用切片方式根据字典键来获取对应值时,如果这个键不存在于字典中就会出现这个错误

解决方法:如果不知道dict中是否有key的值,那么最好用 dict.get(key)如果用dict[key]这个读取会报KeyError异常。

或者,也可以在dict[key]前面加上判断,

if key not in dict:
    continue

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水w

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值