MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / softmax

Function softmax

tools/utils/e2e_utils/extract_textpoint_slow.py:83–91  ·  view source on GitHub ↗

logits: N x d

(logits)

Source from the content-addressed store, hash-verified

81
82
83def softmax(logits):
84 """
85 logits: N x d
86 """
87 max_value = np.max(logits, axis=1, keepdims=True)
88 exp = np.exp(logits - max_value)
89 exp_sum = np.sum(exp, axis=1, keepdims=True)
90 dist = exp / exp_sum
91 return dist
92
93
94def get_keep_pos_idxs(labels, remove_blank=None):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected