【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.

这篇具有很好参考价值的文章主要介绍了【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题详情

AttributeError: module ‘numpy’ has no attribute ‘int’.
np.int was a deprecated alias for the builtin int. To avoid this error in existing code, use int by itself. Doing this will not modify any behavior and is safe.

Traceback (most recent call last):
  File "/home/wh/projects/DenseNet_Demo/train_resnet.py", line 17, in <module>
    from torchtoolbox.transform import Cutout
  File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/__init__.py", line 5, in <module>
    from .autoaugment import *
  File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/autoaugment.py", line 194, in <module>
    Compose([Posterize(0.4, 8), Rotate(0.6, 9)]),
  File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/autoaugment.py", line 104, in __init__
    ranges = np.round(np.linspace(8, 4, 10), 0).astype(np.int)
  File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
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

【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.,疑难问题,numpy,原力计划

问题原因

新版本的numpy里面没有np.int了。

解决方法

第一种,降低numpy版本,安装1.20以下的版本。

pip uninstall numpy

pip install numpy==1.19.0

第二种,修改源码。

ranges = np.round(np.linspace(8, 4, 10), 0).astype(np.int)

修改为:

ranges = np.round(np.linspace(8, 4, 10), 0).astype(int)

如果,对降低numpy版本后,影响到其他的库,可以采用第二种方法。

专栏目录:神经网络精讲与实战

这篇文章,是对专栏的总目录,方便大家查看文章。这个专栏我计划整理一些经典常用的主干网络模型,对其进行讲解和实战。由浅入深,逐步增加深度,让大家更容易接受。

PDF版的文章和实战代码以及数据集,我会放到网盘上,大家在文章的末尾可以看到。

AlexNet

第一篇 AlexNet——论文翻译

第二篇 AlexNet——模型精讲

第三篇 制作数据集

第四篇 AlexNet——网络实战
【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.,疑难问题,numpy,原力计划

VGGNet

第五篇 VGGNet——论文翻译

第六篇 VGGNet——模型精讲

第七篇 图像分类的评价指标

第八篇 VGGNet——网络实战
【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.,疑难问题,numpy,原力计划

GoogLeNet

第九篇 GoogLeNet——论文翻译

第十篇 GoogLeNet——模型精讲

第十一篇 绘图matplotlib.pyplot的使用

第十二篇 GoogLeNet——网络实战
【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.,疑难问题,numpy,原力计划

Inception V2——V4

第十三篇 Inception V2——论文翻译

第十四篇 Inception V3——论文翻译

第十五篇 Inception V4——论文翻译

第十六篇 Inception V2、Inception V3、Inception V4模型详解

第十七篇 PyTorch学习率调整策略

第十八篇 InceptionV3实战

ResNet

第十九篇 ResNet——论文翻译

第二十篇 ResNet——模型讲解

第二十一篇 数据增强

第二十二篇 ResNet实战
【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.,疑难问题,numpy,原力计划

DenseNet

第二十三篇 DenseNet——论文翻译

第二十四篇 DenseNet——模型讲解

第二十五篇 argparse模块

第二十六篇 DenseNet实战

【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.,疑难问题,numpy,原力计划

SE-ResNet

第二十七篇 SeNet——论文翻译

第二十八篇 SeNet模型解析

【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.,疑难问题,numpy,原力计划文章来源地址https://www.toymoban.com/news/detail-626997.html

到了这里,关于【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • 成功解决AttributeError: module ‘numpy‘ has no attribute ‘float‘.

    AttributeError: module ‘numpy’ has no attribute ‘float’. np.float was a deprecated alias for the builtin float . To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. The aliases was originally deprecated in NumPy 1.20; for

    2024年02月16日
    浏览(15)
  • AttributeError: module ‘numpy‘ has no attribute ‘ndarray‘(最新版解决,综合多篇)

    AttributeError: module ‘numpy‘ has no attribute ‘ndarray‘(最新版解决,综合多篇)

    1.进入你 所在环境,分别卸载掉原有的 numpy与pandas 2. 重新安装numpy与pandas,记住先安装numpy,然后安装pandas。 语句1:pip install numpy==1.21.5 -i https://pypi.tuna.tsinghua.edu.cn/simple some-package 语句2:pip install pandas==1.4.3 -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

    2024年02月12日
    浏览(15)
  • AttributeError: module ‘networkx‘ has no attribute ‘from_numpy_matrix‘解决方法

    在我学习louvain算法时,运行了这样一段代码 运行报错 AttributeError: module \\\'networkx\\\' has no attribute \\\'from_numpy_matrix\\\' 问题原因及解决方案: 在 .networkx 3.0 中,变更日志显示以下内容“删 to_numpy_matrix    from_numpy_matrix  (#5746)”  https:/.networkx.org/documentation/stable/release/release_3.0.html 您必

    2024年02月11日
    浏览(8)
  • module ‘numpy‘ has no attribute ‘int‘

    module \\\'numpy\\\' has no attribute \\\'int\\\' 临时解决方法: pip install numpy==1.23 警告: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the pre

    2024年02月12日
    浏览(10)
  • AttributeError: module ‘numpy‘ has no attribute ‘float‘

    出现这个问题的原因是:从numpy1.24起删除了numpy.bool、numpy.int、numpy.float、numpy.complex、numpy.object、numpy.str、numpy.long、numpy.unicode类型的支持。解决上诉问题主要有两种方法: 安装numpy1.24之前的版本 可以用python内置类型或者np.ndarray类型替换: np.float替换为float或者np.float64/np.fl

    2024年02月11日
    浏览(9)
  • python numpy 错误:AttributeError: module ‘numpy‘ has no attribute ‘bool‘

    python numpy 错误:AttributeError: module ‘numpy‘ has no attribute ‘bool‘

    跑代码(pyCUDA,pyTensorRT相关)的时候 numpy 报错 ”AttributeError: module \\\'numpy\\\' has no attribute \\\'bool\\\'“ 把 numpy 从 1.22.x 升级到 1.23.1 灵感来自于下面的回答 https://stackoverflow.com/questions/74893742/how-to-solve-attributeerror-module-numpy-has-no-attribute-bool

    2024年02月12日
    浏览(11)
  • Bug小能手系列(python)_9: 使用sklearn库报错 module ‘numpy‘ has no attribute ‘int‘

    Bug小能手系列(python)_9: 使用sklearn库报错 module ‘numpy‘ has no attribute ‘int‘

    首先,对于自己使用代码 dtype=np.int 报错的情况,建议直接修改为 np.int_ 即可解决,也不用向下看了!!!! 下文主要是针对 sklearn 库包中存在大量np.int报错的情况!!! 在使用 sklearn 库的 metrics 的 cohen_kappa_score() 函数以及 preprocessing.OneHotEncoder 的 fit_transform() 函数时出错。

    2024年02月09日
    浏览(9)
  • 解决AttributeError: module ‘keras‘ has no attribute ……

    在成功解决AttributeError: module ‘keras‘ has no attribute ‘utils‘_new1998的博客-CSDN博客这篇博客中博主有提到如何解决这一问题,其中就是要把 更改成为 而博主不知道其中原因,原因其实是在TensorFlow 2.4及以上版本中, import keras 的方式已经被弃用,取而代之的是 import tensorflow.k

    2024年02月11日
    浏览(15)
  • 解决AttributeError: module tensorflow has no attribute placeholder

    目录 解决AttributeError: module \\\'tensorflow\\\' has no attribute \\\'placeholder\\\' 方法一:升级TensorFlow版本 方法二:使用tf.compat.v1.placeholder替代 方法三:重写代码 应用场景 示例代码 Placeholder 创建和使用placeholder 为placeholder提供数值 placeholder的应用场景 如果你在使用TensorFlow时遇到了\\\"AttributeEr

    2024年02月05日
    浏览(24)
  • 解决AttributeError: module ‘serial‘ has no attribute ‘Serial‘

    最近在搞上位机时遇到了报错AttributeError: module ‘serial’ has no attribute ‘Serial’,翻译过来就是serial类没有Serial对象。然后卡了一个小时才解决,试了网上很多方法,最后才发现报错原因,这问题python也有责任。 下面说下一般的解决方法。 python3之后串口都改为pyserial,seria

    2024年02月02日
    浏览(10)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包