Numpy does not support dtype "long" anymore in the latest version
I am using method stat and it raises an ERROR: "AttributeError: module 'numpy' has no attribute 'long'. Did you mean: 'log'?".
My numpy version is 1.26.0
The error information is:
/home/cai/.local/lib/python3.10/site-packages/torchstat/model_hook.py:65: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.
np.array([parameter_quantity], dtype=np.long))
Traceback (most recent call last):
File "/home/cai/ModelDemos/VGG/vgg19.py", line 18, in <module>
stat(model, input_size)
File "/home/cai/.local/lib/python3.10/site-packages/torchstat/statistics.py", line 71, in stat
ms.show_report()
File "/home/cai/.local/lib/python3.10/site-packages/torchstat/statistics.py", line 64, in show_report
collected_nodes = self._analyze_model()
File "/home/cai/.local/lib/python3.10/site-packages/torchstat/statistics.py", line 57, in _analyze_model
model_hook = ModelHook(self._model, self._input_size)
File "/home/cai/.local/lib/python3.10/site-packages/torchstat/model_hook.py", line 24, in __init__
self._model(x)
File "/home/cai/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/cai/.local/lib/python3.10/site-packages/torchvision/models/vgg.py", line 66, in forward
x = self.features(x)
File "/home/cai/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/cai/.local/lib/python3.10/site-packages/torch/nn/modules/container.py", line 217, in forward
input = module(input)
File "/home/cai/.local/lib/python3.10/site-packages/torchstat/model_hook.py", line 65, in wrap_call
np.array([parameter_quantity], dtype=np.long))
File "/home/cai/.local/lib/python3.10/site-packages/numpy/__init__.py", line 333, in __getattr__
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'long'. Did you mean: 'log'?
I met the same problem. My numpy version is 1.24.4.
The error information is: AttributeError: module 'numpy' has no attribute 'long'
same problem, it seams that you can solve it by downgrade numpy by 1.23.5. ( or maybe under 1.24)
You can find the File "/home/cai/.local/lib/python3.10/site-packages/torchstat/model_hook.py", line 65, in wrap_call and this line of code np.array([parameter_quantity], dtype=np.long)) change dtype=np.long to dtype=np.int64 or dtype=np.int32 or dtype=np.int_. I don't think changing this will cost any problem.
numpy.long was deprecated in numpy 1.20 and removed in numpy 1.24.
To resolve it, you can roll back to a previous version using the following command:
pip install numpy==1.23