当前位置:网站首页>torch. histc
torch. histc
2022-07-01 03:30:00 【It's seventh uncle】
torch.histc
Running small sample segmentation ASGNet When , Calculation mIOU When , stay intersectionAndUnionGPU(output, target, K, ignore_index=255) in , Using the torch.histc Calculate the histogram :
def intersectionAndUnionGPU(output, target, K, ignore_index=255):
# 'K' classes, output and target sizes are N or N * L or N * H * W, each value in range 0 to K - 1.
assert (output.dim() in [1, 2, 3])
assert output.shape == target.shape
output = output.view(-1)
target = target.view(-1)
output[target == ignore_index] = ignore_index
intersection = output[output == target]
area_intersection = torch.histc(intersection, bins=K, min=0, max=K-1)
area_output = torch.histc(output, bins=K, min=0, max=K-1)
area_target = torch.histc(target, bins=K, min=0, max=K-1)
area_union = area_output + area_target - area_intersection
return area_intersection, area_union, area_target
torch.histc Of API:
torch.histc(input, bins=100, min=0, max=0, *, out=None) → Tensor
Calculate the histogram of tensor .
Elements are classified as min and max Between cells of equal width . If min and max All zero , Then use the minimum and maximum values of the data .
Elements below the minimum and above the maximum will be ignored .
Parameters:
input(Tensor)– Input Zhang The amount \color{red}{ tensor } Zhang The amount .bins(int)– Number of histogram boxesmin(int)– The lower limit of the range ( Include )max(int)– The upper limit of the range ( Include )
Returns
output: Histogram with Zhang The amount \color{red}{ tensor } Zhang The amount Tensor The output represents
Example :
>>> torch.histc(torch.tensor([1., 2, 1]), bins=4, min=0, max=3)
Output :tensor([ 0., 2., 1., 0.])
explain : The histogram box is 0、1、2、3;
among
- 0 The quantity of is 0
- 1 The quantity of is 2
- 2 The quantity of is 1
- 3 The quantity of is 0
So the output tensor([0, 2, 1, 0])
边栏推荐
- gcc使用、Makefile总结
- Pathmeasure implements loading animation
- Go tool cli for command line implementation
- C#实现图的深度优先遍历--非递归代码
- Edlines: a real time line segment detector with a false detection control
- Elk elegant management server log
- Stop saying that you can't solve the "cross domain" problem
- How to use hybrid format to output ISO files? isohybrid:command not found
- 多元线性回归
- About the application of MySQL
猜你喜欢

Best used trust automation script (shell)

IPv4和IPv6、局域网和广域网、网关、公网IP和私有IP、IP地址、子网掩码、网段、网络号、主机号、网络地址、主机地址以及ip段/数字-如192.168.0.1/24是什么意思?

伺服第二编码器数值链接到倍福PLC的NC虚拟轴做显示
![[nine day training] content III of the problem solution of leetcode question brushing Report](/img/7e/1e76181e56ef7feb083f9662df71c7.jpg)
[nine day training] content III of the problem solution of leetcode question brushing Report

Edlines: a real time line segment detector with a false detection control

Hello World generation

Druid监控统计数据源

JUC learning

文件上传下载
![[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理](/img/9f/187ca83be1b88630a6c6fbfb0620ed.png)
[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理
随机推荐
10、Scanner.next() 无法读取空格/indexOf -1
Cookie&Session
Md5sum operation
Ouc2021 autumn - Software Engineering - end of term (recall version)
pytorch中的双线性插值上采样(Bilinear Upsampling)、F.upsample_bilinear
Hello World generation
服务器渲染技术jsp
The best learning method in the world: Feynman learning method
go实现命令行的工具cli
JUC学习
过滤器 Filter
How to achieve 0 error (s) and 0 warning (s) in keil5
4、【WebGIS实战】软件操作篇——数据导入及处理
Thread data sharing and security -threadlocal
Redis tutorial
Redis 教程
The shell script uses two bars to receive external parameters
Leetcode 128 longest continuous sequence (hash set)
Best used trust automation script (shell)
Detailed explanation of ES6 deconstruction grammar