!7445 fix some ssd gpu loss is inf

Merge pull request !7445 from TuDouNi/master
This commit is contained in:
mindspore-ci-bot 2020-10-19 16:56:46 +08:00 committed by Gitee
commit 9593e82e56
1 changed files with 2 additions and 1 deletions

View File

@ -124,7 +124,8 @@ def ssd_bboxes_encode(boxes):
bboxes_t = bboxes[index]
default_boxes_t = default_boxes[index]
bboxes_t[:, :2] = (bboxes_t[:, :2] - default_boxes_t[:, :2]) / (default_boxes_t[:, 2:] * config.prior_scaling[0])
bboxes_t[:, 2:4] = np.log(bboxes_t[:, 2:4] / default_boxes_t[:, 2:4]) / config.prior_scaling[1]
tmp = np.maximum(bboxes_t[:, 2:4] / default_boxes_t[:, 2:4], 0.000001)
bboxes_t[:, 2:4] = np.log(tmp) / config.prior_scaling[1]
bboxes[index] = bboxes_t
num_match = np.array([len(np.nonzero(t_label)[0])], dtype=np.int32)