本文整理汇总了Python中mmdet.core.mask_cross_entropy方法的典型用法代码示例。如果您正苦于以下问题:Python core.mask_cross_entropy方法的具体用法?Python core.mask_cross_entropy怎么用?Python core.mask_cross_entropy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mmdet.core
的用法示例。
在下文中一共展示了core.mask_cross_entropy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loss
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import mask_cross_entropy [as 别名]
def loss(self, mask_pred, mask_targets, labels):
loss = dict()
if self.class_agnostic:
loss_mask = mask_cross_entropy(mask_pred, mask_targets,
torch.zeros_like(labels))
else:
loss_mask = mask_cross_entropy(mask_pred, mask_targets, labels)
loss['loss_mask'] = loss_mask
return loss
示例2: loss_aux
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import mask_cross_entropy [as 别名]
def loss_aux(self, mask_pred, mask_targets, labels, alpha=0.25):
loss = dict()
mask_pred_level0 = mask_pred[0::4,:]
mask_pred_level1 = mask_pred[1::4,:]
mask_pred_level2 = mask_pred[2::4,:]
mask_pred_level3 = mask_pred[3::4,:]
if self.class_agnostic:
loss_mask_level0 = mask_cross_entropy(mask_pred_level0, mask_targets,
torch.zeros_like(labels))
loss_mask_level1 = mask_cross_entropy(mask_pred_level1, mask_targets,
torch.zeros_like(labels))
loss_mask_level2 = mask_cross_entropy(mask_pred_level2, mask_targets,
torch.zeros_like(labels))
loss_mask_level3 = mask_cross_entropy(mask_pred_level3, mask_targets,
torch.zeros_like(labels))
else:
loss_mask_level0 = mask_cross_entropy(mask_pred_level0, mask_targets, labels)
loss_mask_level1 = mask_cross_entropy(mask_pred_level1, mask_targets, labels)
loss_mask_level2 = mask_cross_entropy(mask_pred_level2, mask_targets, labels)
loss_mask_level3 = mask_cross_entropy(mask_pred_level3, mask_targets, labels)
loss['loss_mask_level0'] = loss_mask_level0 * alpha
loss['loss_mask_level1'] = loss_mask_level1 * alpha
loss['loss_mask_level2'] = loss_mask_level2 * alpha
loss['loss_mask_level3'] = loss_mask_level3 * alpha
return loss