问题详情
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

问题原因
新版本的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
VGGNet
GoogLeNet
Inception V2——V4
第十六篇 Inception V2、Inception V3、Inception V4模型详解
ResNet
DenseNet

SE-ResNet




