numpy.clip(aa_mina_maxout=None)

Clip (limit) the values in an array.

Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1.

Parameters:

a : array_like

Array containing elements to clip.

a_min : scalar or array_like or None

Minimum value. If None, clipping is not performed on lower interval edge. Not more than one of a_min and a_max may be None.

a_max : scalar or array_like or None

Maximum value. If None, clipping is not performed on upper interval edge. Not more than one of a_min and a_max may be None. If a_min or a_max are array_like, then the three arrays will be broadcasted to match their shapes.

out : ndarray, optional

The results will be placed in this array. It may be the input array for in-place clipping. out must be of the right shape to hold the output. Its type is preserved.

Returns:

clipped_array : ndarray

An array with the elements of a, but where values < a_min are replaced with a_min, and those > a_max with a_max.

Examples

>>> a = np.arange(10)
>>> np.clip(a, 1, 8)
array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8])
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.clip(a, 3, 6, out=a)
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
>>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.clip(a, [3, 4, 1, 1, 1, 4, 4, 4, 4, 4], 8)
array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])

numpy.clip(a, a_min, a_max, out=None)(values < a_min are replaced with a_min, and those > a_max with a_max.)的更多相关文章

  1. Python - numpy.clip()函数

    np.clip( a, a_min, a_max, out=None): 部分参数解释: 该函数的作用是将数组a中的所有数限定到范围a_min和a_max中.a:输入矩阵:a_min:被限定的最小值, ...

  2. 【转】python中numpy模块下的np.clip()的用法

    转自:https://blog.csdn.net/HHTNAN/article/details/79799612 Numpy 中clip函数的使用 一维数组 其中a是一个数组,后面两个参数分别表示最小 ...

  3. numpy 中clip函数的使用

    其中a是一个数组,后面两个参数分别表示最小和最大值 也就是说clip这个函数将将数组中的元素限制在a_min, a_max之间,大于a_max的就使得它等于 a_max,小于a_min,的就使得它等于 ...

  4. Useful NumPy functions: Reshape, Argpartition, Clip, Extract, Setdiff1d

    In everyday data processing for Machine Learning and Data Science projects, we encounter unique situ ...

  5. numpy基础教程--clip函数的使用

    在numpy中,clip函数的原型为clip(self, min=None, max=None, out=None),意思是把小于min的数全部置换为min,大于max的数全部置换为max,在[min ...

  6. numpy及scipy的使用

    numpy的使用 把list A转换为numpy 矩阵 np.array(A) np.array(A, 'int32') numpy加载txt文件里面的矩阵 matrix = np.loadtxt(t ...

  7. 小白眼中的AI之~Numpy基础

      周末码一文,明天见矩阵- 其实Numpy之类的单讲特别没意思,但不稍微说下后面说实际应用又不行,所以大家就练练手吧 代码裤子: https://github.com/lotapp/BaseCode ...

  8. np.clip截取函数

    np.clip截取函数 觉得有用的话,欢迎一起讨论相互学习~Follow Me 将范围外的数强制转化为范围内的数 def clip(a, a_min, a_max, out=None): 将数组a中的 ...

  9. [Python] numpy.random.rand

    numpy.random.rand numpy.random.rand(d0, d1, ..., dn) Random values in a given shape. Create an array ...

随机推荐

  1. 前端之CSS常见兼容性问题

    1.双倍浮动BUG: 描述:块状元素设置了float属性后,又设置了横向的margin值,在IE6下显示的margin值要比设置的值大: 解决方案:给float的元素添加 display:inline ...

  2. uvm_reg_sequence——寄存器模型(六)

    寄存器模型 uvm_reg_sequence是UVM自带所有register sequence 的基类. 该类包含model, adapter, reg_seqr(uvm_sequencer). 感觉 ...

  3. Sublime Text 3 使用小记

    快捷键: [ // 代码对齐插件 { "keys": ["shift+alt+a"], "command": "alignment ...

  4. SQL 转换函数

    1.字符串与字符串相加 字符串相加   得到的是拼接成一列的字符串类型 例如 select name+code from car       name是nvarchar  code也是nvarchar ...

  5. static心得

    TextClass text; 吉晨   static注意 只要显式调用一个类的某一个static变量,那么就会连带static块,所有static变量一起调用,哪怕不去new一个对象,这时候已经对这 ...

  6. config文件声明非系统节点的方法

    有一些自定义节点如果不声明会报出无法识别的节点 XXX 这时候要声明该节点 写法如下 <configSections> <!--声明一个节点组--> <sectionGr ...

  7. k8s学习目录

    目录 K8S基础部分 基础部分 5 秒创建 k8s 集群[转] k8s 核心功能[转] k8s 重要概念[转] 部署 k8s Cluster(上)[转] 部署 k8s Cluster(下)[转] Ku ...

  8. 苹果电脑macbook怎样强制关闭软件

    尝试快捷键Command+Q 选择当前处于界面最前端的应用,同时按住Command+Q退出程序,并不代表强制退出应用,主要用于一些假死的应用. 2 通过快捷键Command+option+Shift+ ...

  9. 安装VC++6.0实验环境

    安装VC++6.0步骤:(1)下载一个压缩包进行解压(2)点击打开解压后的文件(3)找到文件里的程序进行安装(4)等待安装完成该程序后可以试着运行一下此程序,在此我们需要了解编写程序的步骤和注意事项. ...

  10. synchronized 和ReentrantLock的区别

    历史知识:JDK5之前,只有synchronized 可以用,之后就有了ReetrantLock可以用了 ReetrantLock (再入锁) 1.位于java.util.concurrnt.lock ...