MCPcopy Create free account
hub / github.com/tensorflow/models / _compute_softmax

Function _compute_softmax

official/nlp/data/squad_lib.py:913–933  ·  view source on GitHub ↗

Compute softmax probability over raw logits.

(scores)

Source from the content-addressed store, hash-verified

911
912
913def _compute_softmax(scores):
914 """Compute softmax probability over raw logits."""
915 if not scores:
916 return []
917
918 max_score = None
919 for score in scores:
920 if max_score is None or score > max_score:
921 max_score = score
922
923 exp_scores = []
924 total_sum = 0.0
925 for score in scores:
926 x = math.exp(score - max_score)
927 exp_scores.append(x)
928 total_sum += x
929
930 probs = []
931 for score in exp_scores:
932 probs.append(score / total_sum)
933 return probs
934
935
936def generate_tf_record_from_json_file(input_file_path,

Callers 1

postprocess_outputFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected