参考链接: 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相关推荐

  1. python numpy np.finfo()函数 eps

    用法 finfo函数是根据括号中的类型来获得信息,获得符合这个类型的数型 例1: import numpy as np a=np.array([[1],[2],[-1],[0]]) b=np.maxi ...

  2. [转载] python numpy np.exp()函数

    参考链接: Python中的numpy.exp def exp(x, *args, **kwargs): # real signature unknown; NOTE: unreliably rest ...

  3. python numpy np.convolve()函数(返回两个一维序列的离散线性卷积)

    文章目录 from numpy.core.numeric() 计算流程 from numpy.core.numeric() def convolve(a, v, mode='full'):" ...

  4. python numpy np.fromstring()函数(从字符串文本中提取数字,返回一维数组)(爬虫提取数字挺好用的)

    from numpy\core\multiarray.py def fromstring(string, dtype=None, count=-1, sep=''): # real signature ...

  5. Numpy:np.tile()函数

    Numpy:np.tile函数 np.arange()函数 np.tile()函数 np.arange()函数 np.arange()函数返回的是一个有终点和起点的固定步长的排列,其中np.arang ...

  6. python使用np.logspace函数在对数刻度上创建一个对数等距数组实战:在对数刻度上创建一个数组(指定数值个数以及是否包含末尾界值)、使用不同的基数(底数)在对数刻度上构建等距数组、可视化

    python使用np.logspace函数在对数刻度上创建一个对数等距数组实战:在对数刻度上创建一个数组(指定数值个数以及是否包含末尾界值).使用不同的基数(底数)在对数刻度上构建等距数组.可视化 目 ...

  7. python numpy np.argsort()(返回将对数组进行排序的索引)(不懂区别?)

    from numpy\core\fromnumeric.py @array_function_dispatch(_argsort_dispatcher) def argsort(a, axis=-1, ...

  8. python numpy np.lexsort()(使用键序列执行间接稳定排序)(具体没太搞懂区别?)

    from numpy\core_multiarray_umath.py @array_function_from_c_func_and_dispatcher(_multiarray_umath.lex ...

  9. (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, ...

最新文章

  1. 模仿虚基类和抽象方法
  2. MATLAB画图:改变坐标轴刻度的显示数值
  3. android canvas png 失真,【小程序】--------------处理canvas导出图片模糊问题-------------【劉】...
  4. DataGridView控件内建立日期选择编辑列
  5. spring mvc错误收集
  6. linux内核中测量时间的方法,Linux内核中获取时间函数do_gettimeofday
  7. 计算机网络基础专业找工作,2021计算机网络技术前景怎么样? 好找工作吗
  8. jquery实现查看全部示例
  9. Java的线程在哪个地方执行,Java多线程
  10. 老鸟成长之路:菜鸟入门八种安全工具(转)
  11. android 截屏分享权限,android 截屏+保存图片+权限
  12. 西数、希捷、DIY移动硬盘详细拆解,暴力解析
  13. 免费可用的Android手机传感器数据采集程序(附程序)
  14. 个人博客_温州个人博客_Duing-冬忆个人博客
  15. 常见程序(discuz,ecshop,shopex,dedecms等)重置破解管理密码
  16. Error running SecureCardJavaApp. Command line is too long. Shorten the command line and rerun.
  17. java单例模式(下)
  18. Unity Shader-后处理:高斯模糊
  19. 用Python调用Graphviz生成复杂股权关系图
  20. 中国互联网公司都要国际化,美图如何成为出海的另类?

热门文章

  1. Windows cmd终端美化:Windows terminal背景图
  2. 【codevs1163】访问艺术馆
  3. 计算机博士复试英语自我介绍,博士生复试自我介绍的英文
  4. c++ 形参用指针 还是对象_Java 和 C/C++两大高手的对比
  5. python全栈构图_Python全栈-magedu-2018-笔记5
  6. 心电图数据结构化标准_自己实现一个类 JSON 数据结构
  7. 图像过滤,so easy~~
  8. Happy Necklace
  9. 计算机网络中的交换技术
  10. UnityShader6:最简单的顶点/片元着色器