This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
relevance_grades = tf.constant([ | |
[3.0, 2.0, 2.0, 2.0, 1.0], | |
[3.0, 3.0, 1.0, 1.0, 0.0] | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_1 = "dog" | |
bing_search_results = [ | |
"Dog - Wikipedia", | |
"Adopting a dog or puppy | RSPCA Australia", | |
"dog | History, Domestication, Physical Traits, & Breeds", | |
"New South Wales | Dogs & Puppies | Gumtree Australia Free", | |
"dog - Wiktionary" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum(true_prob_dist * np.log(true_prob_dist / true_prob_dist)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum(true_prob_dist * np.log(true_prob_dist / predicted_prob_dist)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raw_relevance_grades = tf.constant([3.0, 1.0, 0.0], dtype=tf.float32) | |
true_prob_dist = tf.nn.softmax(raw_relevance_grades) | |
print(true_prob_dist) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ordered_scores = np.array([scores_dict[x] for x in xlabs]).astype(np.float32) | |
predicted_prob_dist = tf.nn.softmax(ordered_scores) | |
print(predicted_prob_dist) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
np.exp(scores_dict['shirt']) / sum(np.exp(list(scores_dict.values()))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prob_of_permutation = first_term * second_term * third_term | |
print(f"probability of permutation is {prob_of_permutation}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
third_term = 1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
second_term_numerator = np.exp(score_obj_pos_2) | |
second_term_denominator = np.exp(score_obj_pos_2) + np.exp(score_obj_pos_3) | |
second_term = second_term_numerator / second_term_denominator | |
print(f"second term is {second_term}") |