当前位置:网站首页>[PaddleSeg 源码阅读] PaddleSeg计算Dice
[PaddleSeg 源码阅读] PaddleSeg计算Dice
2022-07-04 03:32:00 【氵文大师】
D i c e Dice Dice 系数是一种集合相似度量函数,通常用于计算两个集合的相似度,取值范围是 [ 0 , 1 ] [0, 1] [0,1]:
D i c e ( X , Y ) = 2 ∣ X ∩ Y ∣ ∣ X ∣ + ∣ Y ∣ Dice(X, Y) = \frac {2 | X\cap Y|} { |X| + |Y| } Dice(X,Y)=∣X∣+∣Y∣2∣X∩Y∣
∣ . ∣ |.| ∣.∣ 表示取集合元素的数量函数
D i c e ( X , Y ) = 两 者 交 集 元 素 的 个 数 × 2 两 者 元 素 数 量 之 和 Dice(X, Y) = \frac {两者交集元素的个数 \times 2} {两者元素数量之和} Dice(X,Y)=两者元素数量之和两者交集元素的个数×2
PaddleSeg 中的实现:
def dice(intersect_area, pred_area, label_area):
""" Calculate DICE. 计算 DICE 值. Args: intersect_area (Tensor): The intersection area of prediction and ground truth on all classes. pred_area (Tensor): The prediction area on all classes. label_area (Tensor): The ground truth area on all classes. Returns: np.ndarray: DICE on all classes. float: mean DICE of all classes. """
# 将三者转化为 np.adarray
intersect_area = intersect_area.numpy()
pred_area = pred_area.numpy()
label_area = label_area.numpy()
# 两个集合元素的数量
union = pred_area + label_area
class_dice = []
for i in range(len(intersect_area)): # 在每一类中开始迭代
if union[i] == 0:
# 如果分子为 0,也就是当前图片没有该类元素
dice = 0
else:
dice = (2 * intersect_area[i]) / union[i]
class_dice.append(dice)
mdice = np.mean(class_dice)
return np.array(class_dice), mdice
intersect_area, pred_area, label_area 这三个参数是通过:
calculate_area(pred, label, num_classes, ignore_index=255)
来计算的,接上一篇博客:
[PaddleSeg 源码阅读] PaddleSeg计算 mIoU
边栏推荐
- Stm32bug [stlink forced update prompt appears in keilmdk, but it cannot be updated]
- Dare to climb here, you're not far from prison, reptile reverse actual combat case
- The property of judging odd or even numbers about XOR.
- 96% of the collected traffic is prevented by bubble mart of cloud hosting
- Contest3145 - the 37th game of 2021 freshman individual training match_ D: Ranking
- XSS prevention
- Latex tips slash \backslash
- National standard gb28181 protocol platform easygbs fails to start after replacing MySQL database. How to deal with it?
- Solve the problems encountered by the laravel framework using mongodb
- Contest3145 - the 37th game of 2021 freshman individual training match_ G: Score
猜你喜欢

Summary of Chinese remainder theorem

false sharing

Www 2022 | taxoenrich: self supervised taxonomy complemented by Structural Semantics

Redis transaction

The 37 year old programmer was laid off, and he didn't find a job for 120 days. He had no choice but to go to a small company. As a result, he was confused

Package and download 10 sets of Apple CMS templates / download the source code of Apple CMS video and film website
![[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush](/img/98/3e5f1094141e34d7e77f908e12acda.jpg)
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush

Nbear introduction and use diagram

7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
![[Wu Enda deep learning] beginner learning record 3 (regularization / error reduction)](/img/e9/818bdfeae766dca7d2318b52b4424d.jpg)
[Wu Enda deep learning] beginner learning record 3 (regularization / error reduction)
随机推荐
Tsinghua University product: penalty gradient norm improves generalization of deep learning model
Slurm view node configuration information
Enhanced for loop
Pagoda SSL can't be accessed? 443 port occupied? resolvent
In my spare time, I like to write some technical blogs and read some useless books. If you want to read more of my original articles, you can follow my personal wechat official account up technology c
(practice C language every day) pointer sorting problem
What are the conditions for the opening of Tiktok live broadcast preview?
2022 attached lifting scaffold worker (special type of construction work) free test questions and attached lifting scaffold worker (special type of construction work) examination papers 2022 attached
PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation
Webhook triggers Jenkins for sonar detection
Experience summary of the 12th Blue Bridge Cup (written for the first time)
[untitled]
Stm32bug [the project references devices, files or libraries that are not installed appear in keilmdk]
JSON string conversion in unity
Unspeakable Prometheus monitoring practice
The property of judging odd or even numbers about XOR.
150 ppt! The most complete "fair perception machine learning and data mining" tutorial, Dr. AIST Toshihiro kamishima, Japan
CSP drawing
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
Base d'apprentissage de la machine: sélection de fonctionnalités avec lasso