当前位置:网站首页>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])
边栏推荐
- How to use hybrid format to output ISO files? isohybrid:command not found
- Depth first traversal of C implementation Diagram -- non recursive code
- FCN full Convolution Network Understanding and Code Implementation (from pytorch Official Implementation)
- 第03章_用戶與權限管理
- C language EXECL function
- [us match preparation] complete introduction to word editing formula
- 数据库中COMMENT关键字的使用
- About the application of MySQL
- HTB-Lame
- ECMAScript 6.0
猜你喜欢

深度学习中的随机种子torch.manual_seed(number)、torch.cuda.manual_seed(number)

Ultimate dolls 2.0 | encapsulation of cloud native delivery

过滤器 Filter

LeetCode 128最长连续序列(哈希set)

EtherCAT原理概述

倍福TwinCAT3 Ads相关错误详细列表
![[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation](/img/b3/887d3fb64acbf3702814d32e2e6414.png)
[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation
![[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理](/img/9f/187ca83be1b88630a6c6fbfb0620ed.png)
[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理

Gorilla/mux framework (RK boot): RPC error code design

数据库中COMMENT关键字的使用
随机推荐
Kmeans
Basic concepts of database
leetcode 1482 猜猜看啊,这道题目怎么二分?
C#实现图的深度优先遍历--非递归代码
FCN full Convolution Network Understanding and Code Implementation (from pytorch Official Implementation)
[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation
Stop saying that you can't solve the "cross domain" problem
C language EXECL function
Finally in promise
几行事务代码,让我赔了16万
Split(), split(), slice(), can't you tell?
Let's just say I can use thousands of expression packs
Error accessing URL 404
go实现命令行的工具cli
Introduction to core functions of webrtc -- an article on understanding SDP PlanB unifiedplan (migrating from PlanB to unifiedplan)
Edge drawing: a combined real-time edge and segment detector
如何校验两个文件内容是否相同
Analyze datahub, a new generation metadata platform of 4.7K star
The value of the second servo encoder is linked to the NC virtual axis of Beifu PLC for display
不用加减乘除实现加法