torch.quantile or np.quantile的计算
torch的文档详细说明了quantile的计算方法。
主要是将q的范围[0, 1] 转成输入index的范围[0, n]。 也就是说,将q 乘 n。然后插值计算。
quantile位置不是整数
a = torch.tensor([0.0, 1.1, 2.1, 3.1])
q_result = torch.quantile(a, torch.tensor([0.1, 0.9]))
# tensor([0.3300, 2.8000])
a的index范围: [0, 3]
两个q值0.1, 0.9 都乘以3之后得到0.3, 2.7。
- 0.3在0和1之间,需要插值。缺省插值方法为a + (b-a) * fraction。
0.0+ (1.1 - 0.0)*0.3 = 0.3300
- 2.7在2和3之间
2.1 + (3.1 - 2.1 ) * 0.7 = 2.8000
quantile位置为整数
不需要插值。
例如
a = torch.tensor([0.1, 0.2, 0.3, 0.33, 0.9])
q2 = torch.quantile(a, torch.tensor([0.5]))
# 0.3
0.5 * 4 = 2, 因此取a[2]
torch.quantile or np.quantile的计算相关推荐
- np.quantile()详解
numpy.quantile numpy.quantile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linea ...
- R语言dplyr包group_by函数、quantile函数、summarise函数计算dataframe数据中指定数值数据列在每个分组中的多个分位数值
R语言dplyr包group_by函数.quantile函数.summarise函数计算dataframe数据中指定数值数据列在每个分组中的多个分位数值(Calculate Percentile Va ...
- pandas使用np.where函数计算返回dataframe中指定数据列包含缺失值的行索引列表list
pandas使用np.where函数计算返回dataframe中指定数据列包含缺失值的行索引列表list(index of rows with missing values in dataframe ...
- python使用numpy的np.float_power函数计算numpy数组中每个数值的指定幂次(例如平方、立方)、np.power函数默认返回整数格式、np.float_power函数返回浮点数
python使用numpy的np.float_power函数计算numpy数组中每个数值的指定幂次(例如平方.立方).np.power函数默认返回整数格式.np.float_power函数默认返回浮点 ...
- python使用numpy的np.power函数计算numpy数组中每个数值的指定幂次(例如平方、立方)、np.power函数默认返回整数格式、np.float_power函数默认返回浮点数
python使用numpy的np.power函数计算numpy数组中每个数值的指定幂次(例如平方.立方).np.power函数默认返回整数格式.np.float_power函数默认返回浮点数 目录
- python使用numpy的np.fmod函数计算numpy数组除以某一特定数值剩余的余数(remainder)、np.mod函数和np.fmod函数对负值的处理方式有差异
python使用numpy的np.fmod函数计算numpy数组除以某一特定数值剩余的余数(remainder).np.mod函数和np.fmod函数对负值的处理方式有差异 目录
- python使用numpy中的np.mean函数计算数组的均值、np.var函数计算数据的方差、np.std函数计算数组的标准差
python使用numpy中的np.mean函数计算数组的均值.np.var函数计算数据的方差.np.std函数计算数组的标准差 目录
- PyTorch——torch.Tensor与np.ndarray(NumPy)之间的类型转换
1 前言 今天在写 Digit Recognizer的代码~ 在对提交文件submission.csv进行写入操作的时候,总会有报错,其中一个原因是其实pandas对np.ndarray数据更加友好, ...
- pandas中计算分位数的方法describe,quantile,以及sql中计算分位数的方法percentile_approx,percent_rank() over()
1.pandas中计算分位数的方法describe,quantile 准备一张表 def test():df = pd.DataFrame({'a':[1,2,3],'b':[4,5,6],'c':[ ...
最新文章
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed...
- 你的计算机无法启动一键还原,教你电脑怎么一键还原
- php mysql crud demo_基于php和mysql的简单的dao类实现crud操作功能_PHP教程
- js 当前日期增加自然月
- 屏上有一层紫色(正在找原因)
- wc命令统计文件数据数量信息
- bzoj2462 [BeiJing2011]矩阵模板 hash
- cenyos7安装 yum不可用_centos7安装fabric
- Python自动化中的元素定位xpath(二)
- Android开发入门案例
- 【R语言】R语言在安装与下载时遇到的问题与解决方法
- ctfshow 密码挑战(上)
- PWN之堆利用-unlink攻击
- vue+draggable +jsPlumb 表格数据连线
- 开关二极管IN4148
- 专业办公套件(Office 2019)for Mac
- Mybatis中模糊查询的各种写法
- spring security(三)oauth2
- 16.安全整改.part3
- 7-CNN-minist数据分类