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
scores_dict = {x: np.random.randn(1)[0] for x in ['shirt', 'pants', 'dress']} | |
print(scores_dict) |
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
pi = random.choice(all_permutations) | |
print(pi) |
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
obj_pos_1, obj_pos_2, obj_pos_3 = pi | |
print(f"object at position 1 is '{obj_pos_1}'") | |
print(f"object at position 2 is '{obj_pos_2}'") | |
print(f"object at position 3 is '{obj_pos_3}'") |
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
first_term_numerator = np.exp(score_obj_pos_1) | |
first_term_denominator = np.exp(score_obj_pos_1) + np.exp(score_obj_pos_2) + np.exp(score_obj_pos_3) | |
first_term = first_term_numerator / first_term_denominator | |
print(f"first term is {first_term}" |
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}") |
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
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
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
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
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) |