上述改完还是出现了报错Traceback (most recent call last): File "C:\Users\Administrator\Desktop\Yolodone\train.py", line 543, in <module> train(hyp, opt, device, tb_writer) File "C:\Users\Administrator\Desktop\Yolodone\train.py", line 189, in train dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, File "C:\Users\Administrator\Desktop\Yolodone\utils\datasets.py", line 63, in create_dataloader dataset = LoadImagesAndLabels(path, imgsz, batch_size, File "C:\Users\Administrator\Desktop\Yolodone\utils\datasets.py", line 411, in __init__ bi = np.floor(np.arange(n) / batch_size).astype(np.int) # batch index File "C:\ProgramData\Anaconda3\envs\pytorch1\lib\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
时间: 2023-12-02 19:04:01 浏览: 221
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这个错误是因为在最新版本的numpy中,`np.int`被弃用了,并且在你的代码中仍然在使用它。为了解决这个问题,你需要将代码中所有使用`np.int`的地方替换为`int`。
你可以尝试在`datasets.py`文件的第411行,将`np.int`替换为`int`。例如:
```python
bi = np.floor(np.arange(n) / batch_size).astype(int) # batch index
```
同样,在其他文件中也需要进行相同的更改。
如果你的代码中有其他地方也使用了`np.int`,你需要在所有这些地方进行相应的更改。
完成更改后,重新运行代码,应该就不会再出现该错误了。
阅读全文