[转载] python numpy np.finfo()函数 eps
参考链接: Python中的numpy.log2
用法
finfo函数是根据括号中的类型来获得信息,获得符合这个类型的数型
例1:
import numpy as np
a=np.array([[1],[2],[-1],[0]])
b=np.maximum(a,np.finfo(np.float32).eps)
print(b)
结果:
[[1.0000000e+00]
[2.0000000e+00]
[1.1920929e-07]
[1.1920929e-07]]
例2:
ious = np.maximum(1.0 * inter_area / union_area, np.finfo(np.float32).eps)
eps是取非负的最小值。当计算的IOU为0或为负(但从代码上来看不太可能为负),使用np.finfo(np.float32).eps来替换
doc
finfo(dtype)
Machine limits for floating point types. 浮点类型的机器限制。
Attributes 属性
----------
eps : floating point number of the appropriate type
The smallest representable number such that ``1.0 + eps != 1.0``.
适当类型的浮点数
最小的可表示数字,例如``1.0 + eps!= 1.0''。
epsneg : floating point number of the appropriate type
The smallest representable number such that ``1.0 - epsneg != 1.0``.
适当类型的浮点数
最小的可表示数字,例如``1.0-epsneg!= 1.0''。
iexp : int
The number of bits in the exponent portion of the floating point
representation.
浮点表示形式的指数部分中的位数。
machar : MachAr
The object which calculated these parameters and holds more detailed
information.
计算这些参数并保存更多详细信息的对象。
machep : int
The exponent that yields ``eps``.
产生``eps''的指数。
max : floating point number of the appropriate type
The largest representable number.
适当类型的浮点数
可表示的最大数字。
maxexp : int
The smallest positive power of the base (2) that causes overflow.
导致溢出的基极(2)的最小正功率。
min : floating point number of the appropriate type
The smallest representable number, typically ``-max``.
适当类型的浮点数
最小的可表示数字,通常是“ -max”。
minexp : int
The most negative power of the base (2) consistent with there being
no leading 0s in the mantissa.
基数(2)的最大负幂与尾数中没有前导0一致。
negep : int
The exponent that yields ``epsneg``.
产生``epsneg''的指数。
nexp : int
The number of bits in the exponent including its sign and bias.
指数中的位数,包括其符号和偏差。
nmant : int
The number of bits in the mantissa.
尾数的位数。
precision : int
The approximate number of decimal digits to which this kind of float
is precise.
这种浮点数精确到的近似十进制数字。
resolution : floating point number of the appropriate type
The approximate decimal resolution of this type, i.e.
``10**-precision``.
适当类型的浮点数
此类型的近似十进制分辨率,即``10 **-precision''。
tiny : floating point number of the appropriate type
The smallest-magnitude usable number.
适当类型的浮点数
最小幅度的可用数字。
Parameters
----------
dtype : floating point type, dtype, or instance
The kind of floating point data type to get information about.
浮点类型,dtype或实例
获取有关信息的浮点数据类型的种类。
See Also
--------
numpy.lib.machar.MachAr :
The implementation of the tests that produce this information.
iinfo :
The equivalent for integer data types.
Notes
-----
For developers of numpy: do not instantiate this at the module level. The
initial calculation of these parameters is expensive and negatively impacts
import times. These objects are cached, so calling ``finfo()`` repeatedly
inside your functions is not a problem.
对于numpy的开发人员:不要在模块级别实例化它。
这些参数的初始计算非常昂贵,并且会对导入时间产生负面影响。
这些对象被缓存,因此在函数内重复调用finfo()不会有问题。
示例
>>> from numpy import *
>>> f = finfo(float) # the numbers given are machine dependent
# 给出的数字取决于机器
>>> f.nmant, f.nexp # nr of bits in the mantissa and in the exponent
# 尾数和指数中的位nr
(52, 11)
>>> f.machep # most negative n so that 1.0 + 2**n != 1.0
-52
>>> f.eps # floating point precision: 2**machep
array(2.2204460492503131e-16)
>>> f.precision # nr of precise decimal digits: int(-log10(eps))
15
>>> f.resolution # 10**(-precision)
array(1.0000000000000001e-15)
>>> f.negep # most negative n so that 1.0 - 2**n != 1.0
-53
>>> f.epsneg # floating point precision: 2**negep
array(1.1102230246251565e-16)
>>> f.minexp # most negative n so that 2**n gives normal numbers
-1022
>>> f.tiny # smallest usuable floating point nr: 2**minexp
array(2.2250738585072014e-308)
>>> f.maxexp # smallest positive n so that 2**n causes overflow
1024
>>> f.min, f.max # the most negative and most positive usuable floating number
(-1.7976931348623157e+308, array(1.7976931348623157e+308))
参考文章1:https://scipy.github.io/old-wiki/pages/Numpy_Example_List_With_Doc.html#finfo.28.29
参考文章2:Numpy : 关于np.finfo函数
参考文章3:Numpy 中文用户指南 3.1 数据类型
参考文章4:Python第三方库——Numpy
[转载] python numpy np.finfo()函数 eps相关推荐
- python numpy np.finfo()函数 eps
用法 finfo函数是根据括号中的类型来获得信息,获得符合这个类型的数型 例1: import numpy as np a=np.array([[1],[2],[-1],[0]]) b=np.maxi ...
- [转载] python numpy np.exp()函数
参考链接: Python中的numpy.exp def exp(x, *args, **kwargs): # real signature unknown; NOTE: unreliably rest ...
- python numpy np.convolve()函数(返回两个一维序列的离散线性卷积)
文章目录 from numpy.core.numeric() 计算流程 from numpy.core.numeric() def convolve(a, v, mode='full'):" ...
- python numpy np.fromstring()函数(从字符串文本中提取数字,返回一维数组)(爬虫提取数字挺好用的)
from numpy\core\multiarray.py def fromstring(string, dtype=None, count=-1, sep=''): # real signature ...
- Numpy:np.tile()函数
Numpy:np.tile函数 np.arange()函数 np.tile()函数 np.arange()函数 np.arange()函数返回的是一个有终点和起点的固定步长的排列,其中np.arang ...
- python使用np.logspace函数在对数刻度上创建一个对数等距数组实战:在对数刻度上创建一个数组(指定数值个数以及是否包含末尾界值)、使用不同的基数(底数)在对数刻度上构建等距数组、可视化
python使用np.logspace函数在对数刻度上创建一个对数等距数组实战:在对数刻度上创建一个数组(指定数值个数以及是否包含末尾界值).使用不同的基数(底数)在对数刻度上构建等距数组.可视化 目 ...
- python numpy np.argsort()(返回将对数组进行排序的索引)(不懂区别?)
from numpy\core\fromnumeric.py @array_function_dispatch(_argsort_dispatcher) def argsort(a, axis=-1, ...
- python numpy np.lexsort()(使用键序列执行间接稳定排序)(具体没太搞懂区别?)
from numpy\core_multiarray_umath.py @array_function_from_c_func_and_dispatcher(_multiarray_umath.lex ...
- (python numpy) np.array.shape 中 (3,)、(3,1)、(1,3)的区别
(python numpy) np.array.shape 中 (3,).(3,1).(1,3)的区别 被人问到这个问题,就记录一下吧 1. (3,) (3,)是[x,y,z][x,y,z][x,y, ...
最新文章
- 模仿虚基类和抽象方法
- MATLAB画图:改变坐标轴刻度的显示数值
- android canvas png 失真,【小程序】--------------处理canvas导出图片模糊问题-------------【劉】...
- DataGridView控件内建立日期选择编辑列
- spring mvc错误收集
- linux内核中测量时间的方法,Linux内核中获取时间函数do_gettimeofday
- 计算机网络基础专业找工作,2021计算机网络技术前景怎么样? 好找工作吗
- jquery实现查看全部示例
- Java的线程在哪个地方执行,Java多线程
- 老鸟成长之路:菜鸟入门八种安全工具(转)
- android 截屏分享权限,android 截屏+保存图片+权限
- 西数、希捷、DIY移动硬盘详细拆解,暴力解析
- 免费可用的Android手机传感器数据采集程序(附程序)
- 个人博客_温州个人博客_Duing-冬忆个人博客
- 常见程序(discuz,ecshop,shopex,dedecms等)重置破解管理密码
- Error running SecureCardJavaApp. Command line is too long. Shorten the command line and rerun.
- java单例模式(下)
- Unity Shader-后处理:高斯模糊
- 用Python调用Graphviz生成复杂股权关系图
- 中国互联网公司都要国际化,美图如何成为出海的另类?
热门文章
- Windows cmd终端美化:Windows terminal背景图
- 【codevs1163】访问艺术馆
- 计算机博士复试英语自我介绍,博士生复试自我介绍的英文
- c++ 形参用指针 还是对象_Java 和 C/C++两大高手的对比
- python全栈构图_Python全栈-magedu-2018-笔记5
- 心电图数据结构化标准_自己实现一个类 JSON 数据结构
- 图像过滤,so easy~~
- Happy Necklace
- 计算机网络中的交换技术
- UnityShader6:最简单的顶点/片元着色器