def initialize_weights(self): # Initialize all weights. biases, and initial values self.var_dict = {} # all keys in par with a suffix of '0' are initial values of trainable variables for k, v in par.items(): if k[-1] == '0': name = k[:-1] self.var_dict[name] = tf.Variable(par[k], name) self.syn_x_init = tf.constant(par['syn_x_init']) self.syn_u_init = tf.constant(par['syn_u_init']) if par['EI']: # ensure excitatory neurons only have postive outgoing weights, # and inhibitory neurons have negative outgoing weights self.w_rnn = tf.constant(par['EI_matrix']) @ tf.nn.relu( self.var_dict['w_rnn']) else: self.w_rnn = self.var_dict['w_rnn'] # Make reset operations reset_vars_ops = [] for k, v in self.var_dict.items(): name = k + "0" reset_vars_ops.append(tf.assign(v, par[name])) self.reset_vars_ops = tf.group(*reset_vars_ops)
def initialize_weights(self): self.var_dict = {} # all keys in par with a suffix of '0' are initial values of trainable variables for k, v in par.items(): if k[-1] == '0': name = k[:-1] self.var_dict[name] = tf.Variable(par[k], name) self.syn_x_init = tf.constant(par['syn_x_init']) self.syn_u_init = tf.constant(par['syn_u_init']) if par['EI']: # ensure excitatory neurons only have postive outgoing weights, # and inhibitory neurons have negative outgoing weights self.w_rnn = tf.constant(par['EI_matrix']) @ tf.nn.relu( self.var_dict['w_rnn']) else: self.w_rnn = self.var_dict['w_rnn']