Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
de05f7f0
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
de05f7f0
编写于
6月 19, 2020
作者:
D
dengkaipeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
comment carl
上级
91594e50
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
29 deletion
+18
-29
ppdet/modeling/losses/yolo_loss.py
ppdet/modeling/losses/yolo_loss.py
+18
-29
未找到文件。
ppdet/modeling/losses/yolo_loss.py
浏览文件 @
de05f7f0
...
...
@@ -179,31 +179,20 @@ class YOLOv3Loss(object):
loss_isrp_cls
=
fluid
.
layers
.
reduce_sum
(
loss_isrp_cls
,
dim
=
[
1
,
2
,
3
])
bias
=
0.2
pos_cls_score
=
fluid
.
layers
.
reduce_sum
(
cls_score
*
cls_target
,
dim
=
[
-
1
])
pos_cls_score
=
fluid
.
layers
.
reshape
(
pos_cls_score
,
[
batch_size
,
-
1
,
])
pos_mask
=
fluid
.
layers
.
cast
(
sorted_iou
[:,
:,
0
]
>
0.5
,
dtype
=
'float32'
)
carl_weights
=
bias
+
(
1
-
bias
)
*
pos_cls_score
*
pos_mask
carl_weights
*=
fluid
.
layers
.
reduce_sum
(
pos_mask
)
/
fluid
.
layers
.
reduce_sum
(
carl_weights
)
carl_weights
=
fluid
.
layers
.
reshape
(
carl_weights
,
(
-
1
,
an_num
,
tobj_shape
[
2
],
tobj_shape
[
3
]))
# isr_tobj = tobj * pos_weights
# loss_cls = fluid.layers.sigmoid_cross_entropy_with_logits(cls, tcls)
# pos_mask = fluid.layers.cast(pos_weights > 0., dtype='flaot32')
# orig_loss_cls = fluid.layers.elementwise_mul(loss_cls, tobj * pos_mask, axis=0)
# orig_loss_cls = fluid.layers.reduce_sum(loss_cls)
# orig_loss_cls.stop_gradient = True
# new_loss_cls = fluid.layers.elementwise_mul(loss_cls, isr_tobj * pos_mask, axis=0)
# new_loss_cls = fluid.layers.reduce_sum(loss_cls)
# new_loss_cls.stop_gradient = True
# pos_loss_cls_ratio = orig_loss_cls / new_loss_cls
# bias = 0.2
# pos_cls_score = fluid.layers.reduce_sum(
# cls_score * cls_target, dim=[-1])
# pos_cls_score = fluid.layers.reshape(pos_cls_score, [
# batch_size,
# -1,
# ])
# pos_mask = fluid.layers.cast(
# sorted_iou[:, :, 0] > 0.5, dtype='float32')
# carl_weights = bias + (1 - bias) * pos_cls_score * pos_mask
# carl_weights *= fluid.layers.reduce_sum(
# pos_mask) / fluid.layers.reduce_sum(carl_weights)
# carl_weights = fluid.layers.reshape(carl_weights, (
# -1, an_num, tobj_shape[2], tobj_shape[3]))
loss_x
=
fluid
.
layers
.
sigmoid_cross_entropy_with_logits
(
x
,
tx
)
*
tscale
...
...
@@ -215,8 +204,8 @@ class YOLOv3Loss(object):
loss_h
=
fluid
.
layers
.
abs
(
h
-
th
)
*
tscale
loss_wh
=
loss_w
+
loss_h
loss_carl
=
(
loss_xy
+
loss_wh
)
*
carl_weights
loss_carl
=
fluid
.
layers
.
reduce_sum
(
loss_carl
,
dim
=
[
1
,
2
,
3
])
#
loss_carl = (loss_xy + loss_wh) * carl_weights
#
loss_carl = fluid.layers.reduce_sum(loss_carl, dim=[1, 2, 3])
# loss_x = fluid.layers.reduce_sum(loss_x, dim=[1, 2, 3])
# loss_y = fluid.layers.reduce_sum(loss_y, dim=[1, 2, 3])
...
...
@@ -253,7 +242,7 @@ class YOLOv3Loss(object):
loss_xys
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_xy
))
loss_whs
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_wh
))
loss_isrp_clss
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_isrp_cls
))
loss_carls
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_carl
))
#
loss_carls.append(fluid.layers.reduce_mean(loss_carl))
loss_objs
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_obj_pos
+
loss_obj_neg
))
loss_clss
.
append
(
fluid
.
layers
.
reduce_mean
(
loss_cls
))
...
...
@@ -262,7 +251,7 @@ class YOLOv3Loss(object):
"loss_xy"
:
fluid
.
layers
.
sum
(
loss_xys
),
"loss_wh"
:
fluid
.
layers
.
sum
(
loss_whs
),
"loss_isrp_cls"
:
fluid
.
layers
.
sum
(
loss_isrp_clss
),
"loss_carl"
:
fluid
.
layers
.
sum
(
loss_carls
),
#
"loss_carl": fluid.layers.sum(loss_carls),
"loss_obj"
:
fluid
.
layers
.
sum
(
loss_objs
),
"loss_cls"
:
fluid
.
layers
.
sum
(
loss_clss
),
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录