码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.


    文章目录

    • 问题详情
    • 问题原因
    • 解决方法
    • 专栏目录:神经网络精讲与实战
    • AlexNet
    • VGGNet
    • GoogLeNet
    • Inception V2——V4
    • ResNet
    • DenseNet
    • SE-ResNet

    问题详情

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    在这里插入图片描述

    问题原因

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

    解决方法

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

    pip uninstall numpy
    
    pip install numpy==1.19.0
    
    • 1
    • 2
    • 3

    第二种,修改源码。
    将

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

    修改为:

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

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

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

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

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

    AlexNet

    第一篇 AlexNet——论文翻译

    第二篇 AlexNet——模型精讲

    第三篇 制作数据集

    第四篇 AlexNet——网络实战
    在这里插入图片描述

    VGGNet

    第五篇 VGGNet——论文翻译

    第六篇 VGGNet——模型精讲

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

    第八篇 VGGNet——网络实战
    在这里插入图片描述

    GoogLeNet

    第九篇 GoogLeNet——论文翻译

    第十篇 GoogLeNet——模型精讲

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

    第十二篇 GoogLeNet——网络实战
    在这里插入图片描述

    Inception V2——V4

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

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

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

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

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

    第十八篇 InceptionV3实战

    ResNet

    第十九篇 ResNet——论文翻译

    第二十篇 ResNet——模型讲解

    第二十一篇 数据增强

    第二十二篇 ResNet实战
    在这里插入图片描述

    DenseNet

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

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

    第二十五篇 argparse模块

    第二十六篇 DenseNet实战

    在这里插入图片描述

    SE-ResNet

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

    第二十八篇 SeNet模型解析

  • 相关阅读:
    IPD(集成产品开发)—核心思想
    新员工碰到新问题 公司论坛帮解决
    Revit二次开发 创建空心模型并与指定构件剪切
    Codeforces Global Round 21 C D E
    debian/ubuntu 编译安装nginx php
    【MySQL】事务 详解
    使用 Docker 自建一款怀旧游戏之 - 超级马里奥
    High-Resolution Network (篇一):原理刨析
    代数、图算法:图基础
    Python与Conda创建虚拟环境
  • 原文地址:https://blog.csdn.net/hhhhhhhhhhwwwwwwwwww/article/details/131430993
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号