def visited(self): """ Return a list of visited nodes. """ # assert nodes have been visited assert self.r.sum() != 0 x = np.where(self.r > 0)[1] visited = remove_array_duplicates(x) return visited
# wrong response so simulation runs a bit longer # which leaves extra space after the winner # has been picked problem = ['river', 'note', 'account'] target = 'house' param = {'max_visited': 5, 'stim_len': 50} # run the simulation network = Network(**param) network.setup_problem(problem, target) network.run() # get indices of winning units winners = np.where(network.w > network.theta_w)[1] unique_win = remove_array_duplicates(winners) for i in unique_win: print network.ids[i], network.a[network.t_max, i] # get activated units which are not winners background = np.where(network.a > 0.1)[1] background = set(background) ids = list(background) idswc = list(set(ids) - set(network.cue_ids)) p, n = len(unique_win), network.t_max X = np.linspace(0, 2, n) Ya = network.a[:n, ids].T
# which leaves extra space after the winner # has been picked problem = ['river', 'note', 'account'] target = 'house' param = {'max_visited': 5, 'stim_len': 50} # run the simulation network = Network(**param) network.setup_problem(problem, target) network.run() # get indices of winning units winners = np.where(network.w > network.theta_w)[1] unique_win = remove_array_duplicates(winners) for i in unique_win: print network.ids[i], network.a[network.t_max, i] # get activated units which are not winners background = np.where(network.a > 0.1)[1] background = set(background) ids = list(background) idswc = list(set(ids) - set(network.cue_ids)) p, n = len(unique_win), network.t_max X = np.linspace(0, 2, n) Ya = network.a[:n, ids].T