Skip to content

Commit

Permalink
Corrected float32 downcast
Browse files Browse the repository at this point in the history
  • Loading branch information
williampeer committed Apr 2, 2016
1 parent bf963c4 commit d9788de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Experiments_4_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def training_and_recall_hpc_helper(hpc, training_set_size, train_set_num, origin
# print "Neuronal turnover completed in", "{:7.3f}".format(t1-t0), "seconds."
# hpc.re_wire_fixed_input_to_ec_weights()
print "Learning patterns in training set..."
hpc_learn_patterns_wrapper(hpc, patterns=training_set, max_training_iterations=50) # when training is fixed,
hpc_learn_patterns_wrapper(hpc, patterns=training_set, max_training_iterations=30) # when training is fixed,
# convergence should occur after one or two iterations?

# extract by chaotic recall:
Expand Down
23 changes: 12 additions & 11 deletions HPC.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,28 +468,29 @@ def reset_hpc_module(self):
input_ec_weights = Tools.binomial_f(dims[0], dims[1], self.connection_rate_input_ec)
self.update_input_ec_weights(input_ec_weights)

# randomly assign all weights between the EC and CA3
ec_ca3_weights = np.random.normal(0.5, np.sqrt(0.25), (dims[1], dims[3])).astype(np.float32)

# randomly assign about 25 % of the weights to a random connection weight
ec_dg_weights = Tools.binomial_f(dims[1], dims[2], self.PP) * np.random.normal(0.5, 0.5, (dims[1], dims[2]))
ec_dg_weights = Tools.binomial_f(dims[1], dims[2], self.PP) * np.random.normal(0.5, 0.5, (dims[1], dims[2])).astype(np.float32)

# randomly assign about 4 % of the weights to random connection weights
dg_ca3_weights = Tools.binomial_f(dims[2], dims[3], self.MF) * \
np.random.normal(0.9, np.sqrt(0.01), (dims[2], dims[3])) # elemwise
np.random.normal(0.9, np.sqrt(0.01), (dims[2], dims[3])).astype(np.float32) # elemwise

# randomly assign 100 % of the weights between CA3 and CA3
ca3_ca3_weights = np.random.normal(0.5, np.sqrt(0.25), (dims[3], dims[3]))
ca3_ca3_weights = np.random.normal(0.5, np.sqrt(0.25), (dims[3], dims[3])).astype(np.float32)

# random weight assignment, full connection rate CA3-out
ca3_output_weights = np.random.normal(0., np.sqrt(0.5), (dims[3], dims[4]))
ca3_output_weights = np.random.normal(0., np.sqrt(0.5), (dims[3], dims[4])).astype(np.float32)

new_Ws = T.fmatrix("new_Ws")
update_ec_dg_Ws = theano.function([new_Ws], updates=(self.ec_dg_weights, new_Ws))
update_ec_ca3_Ws = theano.function([new_Ws], updates=(self.ec_ca3_weights, new_Ws))
update_dg_ca3_Ws = theano.function([new_Ws], updates=(self.dg_ca3_weights, new_Ws))
update_ca3_ca3_Ws = theano.function([new_Ws], updates=(self.ca3_ca3_weights, new_Ws))
update_ca3_out_Ws = theano.function([new_Ws], updates=(self.ca3_out_weights, new_Ws))
update_ec_dg_Ws = theano.function([new_Ws], updates=[(self.ec_dg_weights, new_Ws)])
update_ec_ca3_Ws = theano.function([new_Ws], updates=[(self.ec_ca3_weights, new_Ws)])
update_dg_ca3_Ws = theano.function([new_Ws], updates=[(self.dg_ca3_weights, new_Ws)])
update_ca3_ca3_Ws = theano.function([new_Ws], updates=[(self.ca3_ca3_weights, new_Ws)])
update_ca3_out_Ws = theano.function([new_Ws], updates=[(self.ca3_out_weights, new_Ws)])

# randomly assign all weights between the EC and CA3
ec_ca3_weights = np.random.normal(0.5, np.sqrt(0.25), (dims[1], dims[3]))
update_ec_dg_Ws(ec_dg_weights)
update_ec_ca3_Ws(ec_ca3_weights)
update_dg_ca3_Ws(dg_ca3_weights)
Expand Down

0 comments on commit d9788de

Please sign in to comment.