Skip to content

Commit 258772a

Browse files
author
Songki Choi
authored
Fix NaN issue for exp() in softmax function (#3490)
Signed-off-by: Songki Choi <[email protected]>
1 parent dc39204 commit 258772a

File tree

1 file changed

+1
-1
lines changed
  • demos/common/python/openvino/model_zoo/model_api/models

1 file changed

+1
-1
lines changed

demos/common/python/openvino/model_zoo/model_api/models/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,5 @@ def nms(x1, y1, x2, y2, scores, thresh, include_boundaries=False, keep_top_k=Non
209209

210210

211211
def softmax(logits, axis=None, keepdims=False):
212-
exp = np.exp(logits)
212+
exp = np.exp(logits - np.max(logits))
213213
return exp / np.sum(exp, axis=axis, keepdims=keepdims)

0 commit comments

Comments
 (0)