Skip to content

Commit

Permalink
Refactored.
Browse files Browse the repository at this point in the history
  • Loading branch information
williampeer committed Mar 30, 2016
1 parent 3b7aa92 commit 3598323
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Experiments_4_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ def training_and_recall_hpc_helper(hpc, training_set_size, train_set_num, origin
# convergence should occur after one or two iterations?

# extract by chaotic recall:
print "Recalling patterns for 300 time-steps by chaotic recall..."
chaotic_recall_iters = 100
print "Recalling patterns for", chaotic_recall_iters, "time-steps by chaotic recall..."
t2 = time.time()
[patterns_extracted_for_current_set, random_in] = \
hpc_chaotic_recall_wrapper(hpc, display_images_of_stable_output=False, recall_iterations=100)
hpc_chaotic_recall_wrapper(hpc, display_images_of_stable_output=False, recall_iterations=chaotic_recall_iters)
for pat in patterns_extracted_for_current_set:
if not set_contains_pattern(hippocampal_chaotic_recall_patterns, pat):
hippocampal_chaotic_recall_patterns.append(pat) # append unique pattern
Expand Down
8 changes: 4 additions & 4 deletions HPC.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, dims, connection_rate_input_ec, perforant_path, mossy_fibers,

# randomly assign all weights between the EC and CA3
# ec_ca3_weights = uniform_f(dims[1], dims[3])
ec_ca3_weights = np.random.normal(0.5, 0.25, (dims[1], dims[3]))
ec_ca3_weights = binomial_f(dims[1], dims[3], self.PP) * np.random.normal(0.5, 0.25, (dims[1], dims[3]))
self.ec_ca3_weights = theano.shared(name='ec_ca3_weights', value=ec_ca3_weights.astype(theano.config.floatX),
borrow=True)

Expand Down Expand Up @@ -143,8 +143,8 @@ def __init__(self, dims, connection_rate_input_ec, perforant_path, mossy_fibers,
c_nu_ca3 = T.fmatrix()
c_zeta_ca3 = T.fmatrix()

ca3_input_sum = c_ec_vals.dot(c_ec_ca3_Ws) + c_dg_vals.dot(c_dg_ca3_Ws) + c_ca3_vals.dot(c_ca3_ca3_Ws)
# ca3_input_sum = c_ec_vals.dot(c_ec_ca3_Ws) + 25 * c_dg_vals.dot(c_dg_ca3_Ws) + c_ca3_vals.dot(c_ca3_ca3_Ws)
# ca3_input_sum = c_ec_vals.dot(c_ec_ca3_Ws) + c_dg_vals.dot(c_dg_ca3_Ws) + c_ca3_vals.dot(c_ca3_ca3_Ws)
ca3_input_sum = c_ec_vals.dot(c_ec_ca3_Ws) + 25 * c_dg_vals.dot(c_dg_ca3_Ws) + c_ca3_vals.dot(c_ca3_ca3_Ws)
nu_ca3 = self._k_m * c_nu_ca3 + ca3_input_sum
zeta_ca3 = self._k_r * c_zeta_ca3 - self._alpha * c_ca3_vals + self._a_i
next_activation_values_ca3 = T.tanh((nu_ca3 + zeta_ca3) / self._epsilon)
Expand Down Expand Up @@ -274,7 +274,7 @@ def kWTA(self, values, f_r):

sort_values_f = theano.function([], outputs=T.sort(values))
sorted_values = sort_values_f()
k_th_largest_value = sorted_values[0][values_length-k-1]
k_th_largest_value = (sorted_values[0][values_length-k-1] + sorted_values[0][values_length-k-2]) / 2

mask_vector = k_th_largest_value * np.ones_like(values)
result = (values >= mask_vector).astype(np.float32)
Expand Down

0 comments on commit 3598323

Please sign in to comment.