贝叶斯损耗衰减的物体检测

时间:2019-07-02 15:58:05

标签: object-detection

我想根据本文创建损失函数(http://mediatum.ub.tum.de/doc/1463390/488043490645.pdf

为此,我必须根据该论文添加方差层来更改当前的SSD对象检测器

我的问题是我们如何在ssd模型上创建方差层

我们如何为盒子和类创建损失函数

我尝试如下在ssd上创建图层

但我不确定是否与论文中所述

相同
classes4_reshaped = Reshape((-1, num_classes), name='classes4_reshape')(classes4)
#We added dropout layer because yarian gal said that dropout layer should added before output layer & on top of fully connected layer
classes4_reshaped = Dropout(0.5)(classes4_reshaped)
classes5_reshaped = Reshape((-1, num_classes), name='classes5_reshape')(classes5)
classes5_reshaped = Dropout(0.5)(classes5_reshaped)
classes6_reshaped = Reshape((-1, num_classes), name='classes6_reshape')(classes6)
classes6_reshaped = Dropout(0.5)(classes6_reshaped)
classes7_reshaped = Reshape((-1, num_classes), name='classes7_reshape')(classes7)
classes7_reshaped = Dropout(0.5)(classes7_reshaped)

# Reshape the box coordinate predictions, yielding 3D tensors of shape `(batch, height * width * n_boxes, 4)`
# We want the four box coordinates isolated in the last axis to compute the smooth L1 loss
boxes4_reshaped = Reshape((-1, 4), name='boxes4_reshape')(boxes4)
boxes4_reshaped = Dropout(0.5)(boxes4_reshaped)
boxes5_reshaped = Reshape((-1, 4), name='boxes5_reshape')(boxes5)
boxes5_reshaped = Dropout(0.5)(boxes5_reshaped)
boxes6_reshaped = Reshape((-1, 4), name='boxes6_reshape')(boxes6)
boxes6_reshaped = Dropout(0.5)(boxes6_reshaped)
boxes7_reshaped = Reshape((-1, 4), name='boxes7_reshape')(boxes7)
boxes7_reshaped = Dropout(0.5)(boxes7_reshaped)

anchors4_reshaped = Reshape((-1, 8), name='anchors4_reshape')(anchors_4)
anchors5_reshaped = Reshape((-1, 8), name='anchors5_reshape')(anchors_5)
anchors6_reshaped = Reshape((-1, 8), name='anchors6_reshape')(anchors_6)
anchors7_reshaped = Reshape((-1, 8), name='anchors7_reshape')(anchors_7)

variance_pre =密集(1,name ='variance_pre')(classes_concat)     方差=激活('softplus',名称='方差')(variance_pre)

logits_variance_class = Concatenate(axis=2,name='logits_variance_class')([classes_concat, variance])

boxes_concat = Concatenate(axis=1, name='boxes_concat')([boxes4_reshaped,
                                                         boxes5_reshaped,
                                                         boxes6_reshaped,
                                                         boxes7_reshaped])


variance_pre_box = Dense(1, name='variance_pre_box')(boxes_concat)
variance_box = Activation('softplus', name='variance_box')(variance_pre_box)

logits_variance_box =串联(轴= 2,名称='logits_variance_box')([boxes_concat,variance_box])

logits_variance_class =并置(axis = 2,name ='logits_variance_class')([[classes_concat,variation])

logits_variance =串联(axis = 2,name ='logits_variance')([logits_variance_class,logits_variance_box,anchors_concat])

model2 =模型(输入= x,输出= logits_variance)

我需要一些建议,根据本文我们必须如何执行模型和损失方程。

0 个答案:

没有答案