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. 终于 Vue.js 成为世界一流的框架

    终于 Vue.js 成为世界一流的框架 随着美团开源基于 Vue.js 的微信小程序框架 mpvue, Vue.js 在微信小程序端的能力被补齐,于是 Vue.js 成为了一个唯一能在 Web, H5 ...

  2. tomcat启动时自动运行代码

    原文链接:http://jingpin.jikexueyuan.com/article/49660.html 作者: 一直向北 发布时间:2015-07-13 11:12:13 方法1:tomcat ...

  3. 解决java.lang.NoClassDefFoundError: javax/xml/rpc/service错误的方法

    最近在做WebService项目,本地测试没有问题,打算部署到服务器上,但是部署后,访问时出现了如下图1的错误: 图1 图1报的是没有找到定义的类的错误.刷新页面有又出现了另外“新”的错误: 图2 根 ...

  4. 如何计算支撑向量数(SVs)

    申明:转载请注明出处. 支持向量机(SVM)是一个成熟的单分类器,常常用于对比实验中.往往需要统计支持向量数量来比较算法优劣,MATLAB有自带的SVM工具箱,用法如下: [train, test] ...

  5. SQLite连接

    SQLite -连接 SQLite的联接子句用于从数据库中的两个或多个表合并的记录.JOIN是用于通过使用共同的每个值从两个表结合域的装置. SQL定义了三个主要类型的连接: CROSS JOIN I ...

  6. MVC简单登陆验证

    配置文件: <system.web> <authentication mode="Forms"> <!-- 如果验证失败就返回URL的指定界面,设置c ...

  7. Makefile入门教程

    Makefile介绍 make是一个命令工具,它解释Makefile 中的指令(应该说是规则).在Makefile文件中描述了整个工程所有文件的编译顺序.编译规则.Makefile 有自己的书写格式. ...

  8. 修改linux的时区问题

    修改linux的时区问题 配置服务器节点上的时区的步骤: 1.先生成时区配置文件Asia/Shanghai,用交互式命令 tzselect 即可: 2.拷贝该时区文件,覆盖系统本地时区配置: cp / ...

  9. Python基础篇 -- 运算符和编码

    运算符 记熟 ! ! ! 2**1=2 2**2=4 2**3=8 2**4=16 2**5=32 2**6=64 2**7=128 2**8=256 2**9=512 2**10=1024 运算符 ...

  10. Hello World投票以太坊Dapp教程-Part1

    参考资料:https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0 ...