Skip to content

Commit

Permalink
Merge pull request #2 from YaBoiSkinnyP/improve-project-structure
Browse files Browse the repository at this point in the history
Improve project structure
  • Loading branch information
TheJDen authored Oct 17, 2023
2 parents 53817e3 + 2018a84 commit 2d1d835
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import numpy_guesser as npg
from functools import partial
# shape-preserving normalization

def normalized(log_probabilities: np.array) -> np.array:
Expand Down Expand Up @@ -32,8 +33,8 @@ def intercepter_random_variables(word_index, initial_distribution_func=equal_ini
def updated_random_vars(clue_and_keyword_to_log_probability_func, random_vars: list[npg.NumpyRandomVariable], clue_indices: np.ndarray, correct_code: np.ndarray, probability_reshape=lambda x: x):
var_log_probabilities = np.array([random_var.log_probabilities for random_var in random_vars])
var_keyword_indices = np.array([random_var.keyword_indices for random_var in random_vars])
keyword_to_log_prob_vectorized = partial(clue_and_keyword_to_log_probability_func, clue_indices)
log_association_probabilities = keyword_to_log_prob_vectorized(var_keyword_indices[correct_code])
reshaped_log_associatipon_probabilities = probability_reshape(log_association_probabilities)
var_log_probabilities[correct_code] += reshaped_log_associatipon_probabilities
keyword_to_log_prob = partial(clue_and_keyword_to_log_probability_func, clue_indices)
log_association_probabilities = keyword_to_log_prob(var_keyword_indices[correct_code])
reshaped_log_association_probabilities = probability_reshape(log_association_probabilities)
var_log_probabilities[correct_code] += reshaped_log_association_probabilities
return [npg.NumpyRandomVariable(normalized(log_probabilities), keyword_indices) for log_probabilities, keyword_indices in zip(var_log_probabilities, var_keyword_indices)]
Loading

0 comments on commit 2d1d835

Please sign in to comment.