在ANACONDA中安装mxnet报错处理

错误

AttributeError: module 'numpy' has no attribute 'bool'. np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

分析

这个错误是由于 numpy 版本 1.20 及以上不再支持 np.bool,它已经被弃用并移除,应该改为使用 Python 内建的 boolnp.bool_ 来代替。

解决方法

但是我们不对代码进行修改,我们先对numpy进行降级。

conda install numpy=1.19

或者

pip install numpy==1.19

尝试安装 mxnet 的早期版本。

conda install mxnet=1.8.0

或者

pip install mxnet==1.8.0

接下来即可正常运行。

范例

import mxnet as mx
from mxnet import nd

# 初始化数组
x = nd.array([[1, 2], [3, 4]])

# 打印数组
print(x)

# 计算矩阵乘法
y = x * x.T
print(y)

返回结果:

[[1. 2.]
 [3. 4.]]
<NDArray 2x2 @cpu(0)>

[[ 1.  6.]
 [ 6. 16.]]
<NDArray 2x2 @cpu(0)>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

成为不掉头发的工程师

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

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

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

打赏作者

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

抵扣说明:

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

余额充值