module 'numpy' has no attribute 'bool'
module 'numpy' has no attribute 'bool'
问题:
Traceback (most recent call last):
File "/home/test.py", line 138, in <module>
inference(args, net, test_save_path)
File "/home/test.py", line 54, in inference
metric_i = test_single_volume(image, label, model, classes=args.num_classes, patch_size=[args.img_size, args.img_size],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/utils.py", line 90, in test_single_volume
metric_list.append(calculate_metric_percase(prediction == i, label == i))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/utils.py", line 52, in calculate_metric_percase
dice = metric.binary.dc(pred, gt)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anaconda3/envs/python311/lib/python3.11/site-packages/medpy/metric/binary.py", line 68, in dc
result = numpy.atleast_1d(result.astype(numpy.bool))
^^^^^^^^^^
File "/home/anaconda3/envs/python311/lib/python3.11/site-packages/numpy/__init__.py", line 324, in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
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. Did you mean: 'bool_'?
原因:
不推荐使用np.bool和np.int等内置类型。在Numpy1.24.0 中不推荐的类型已经完全移除。当使用旧版本的时候就会出现这个问题。
解决:
使用未移除前的版本诸如numpy==1.23.2
pip install numpy==1.23.2
module 'numpy' has no attribute 'bool'的更多相关文章
- 【Python 数据分析】module 'numpy' has no attribute 'array'
安装好Numpy模块后,开始做了几个小测试都可以运行,但是当我创建numpy.py这个文件后 numpy.py import numpy y = numpy.array([[11,4,2],[2,6, ...
- Pytorch:module 'torch' has no attribute 'bool'
Pytorch:module 'torch' has no attribute 'bool' 这个应该是有些版本的Pytorch会遇到这个问题,我用0.4.0版本测试发现torch.bool是有的,但 ...
- AttributeError: module 'numpy' has no attribute 'num'
AttributeError: module 'numpy' has no attribute 'num' 写在前面 总的来说,先看看自己用的计算方式是不是写对了先,多个一起使用的话记得都看看 通过想 ...
- Python基础学习-'module' object has no attribute 'urlopen'解决方法
import numpy as npimport urlliburl = "http://archive.ics.uci.edu/ml/machine-learning-databases/ ...
- 解决:pipenv shell报错:AttributeError: 'module' object has no attribute 'run'
利用pipenv shell切换到虚拟环境时,显示报错:AttributeError: 'module' object has no attribute 'run' 可以看到是d:\program\p ...
- module 'cv2' has no attribute 'KNearest_create'
python版本:3.6.5 opencv版本:3.2.0 使用的是jupyter notebook 源代码如下: import cv2 import numpy as np import matpl ...
- python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?
python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- attributeError:'module' object has no attribute ** 解决办法
写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...
- AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'
/*************************************************************************** * AttributeError: 'modu ...
随机推荐
- Office Online Server Windows Server 2016 部署
一.准备"武器" 本文是通过虚拟机搭建 OOS 测试环境的,4567是3的前提,武器提取 le73 1.VMWare Workstation 17 Player 2.Windows ...
- Linux进程的创建与销毁
Linux操作系统是一种多任务.多用户的操作系统,这意味着它可以同时运行多个进程,每个进程都可以执行不同的任务. 在本文中,我们将介绍如何在Linux系统中创建和销毁进程. 进程的创建 在Linux系 ...
- 【分布式】load balance 04-java 从零手写实现负载均衡
负载均衡系列专题 01-负载均衡基础知识 02-一致性 hash 原理 03-一致性哈希算法 java 实现 04-负载均衡算法 java 实现 本节我们来看一下如何实现一负载均衡框架. 源码 核心接 ...
- MySQL8.0使用mysqlsh配置主从复制 InnoDB ReplicaSet
InnoDB ReplicaSet InnoDB ReplicaSet 由一个主节点和多个从节点构成. 可以使用ReplicaSet对象和AdminAPI操作管理复制集, 例如检查InnoDB复制集的 ...
- ROS2 humble交叉编译环境配置
目录 配置 toolchain文件: 库文件 交叉编译指令: 问题点: 1.find_package找不到自定义依赖包的问题 2.libarmadillo.so.10: undefined refer ...
- 6大数据类型之间的转换及数据在内存中的缓存机制----day03
1.自动类型转换 当2个不同类型的数据进行运算的时候,默认向更高精度转换 数据类型精度从低到高:bool < int < float <complex 1,1强制类型转换 # Nu ...
- python各版本新特性
# py3.7 https://docs.python.org/zh-cn/3/whatsnew/3.7.html # py3.8 https://docs.python.org/zh-cn/3/wh ...
- java+mysql实现的公益管理系统
一功能 1.管理员的登录 2.公益项目的增删改查 3.负责人的增删改查 4.捐款人的增删改查 5.志愿者增删改查 二界面展示 1.欢迎界面 2.登录界面 3.系统首页 4.项目管理 5.负责人管理 6 ...
- Elasticsearch系列之-windows安装和基础操作
ElasticSearch安装 安装JDK环境 因为ElasticSearch是用Java语言编写的,所以必须安装JDK的环境,并且是JDK 1.8以上 官网:https://www.oracle.c ...
- Java面向对象之接口和抽象类的区别一目了然
介绍 相信对于Java面向对象部分,很多人很长一段时间对于接口和抽象类的区别,使用场景都不是很熟悉,同是作为抽象层重要的对象,工作中到底什么情况下使用抽象类,不是很清楚.本文就一次性把这些概念一次性说 ...