def Machine(jEE=1, extE=1, dist=3): ### Get Standard Parameters ### info = numParam() _, toDo = doParam() ### Specify Parameters ### toDo["switch"] = 1 info["j_EE"] = jEE info["extM"][0] = extE info["dist"] = dist info['recNum'] = 100 # info['sizeM'][0] ### Create constant inputs to function ### jCon = nn.createjCon(info) external = nn.createExt(info) thresh = nn.createThresh(info["sizeM"], info["threshM"], toDo["doThresh"]) ### Run System ### (indiNeuronsDetailed, activeOT, fireOT, labels_train) = nn.run_update(jCon, thresh, external, info, toDo) activeOT = np.array(activeOT) ### correctness = predic_readout(activeOT, labels_train, info) contrib = np.mean(indiNeuronsDetailed[:info["recNum"]][:], axis=(0, 1)) overall_activity = contrib[3] ratio_ext_int = contrib[3] / contrib[4] useless(indiNeuronsDetailed, fireOT) return correctness, overall_activity, ratio_ext_int, internal
def changeThresh_(): check_plt() ### Specify Parameters name = "thresh" info = numParam(name) (drw, toDo) = doParam() ### Create constant inputs to function jCon = nn.createjCon(info) external = nn.createExt(info) doThresh = ["constant", "gauss", "bound"] for i in range(len(doThresh)): toDo["doThresh"] = doThresh[i] thresh = nn.createThresh(info["sizeM"], info["threshM"], toDo["doThresh"]) ( indiNeuronsDetailed, activeOT, fireOT, _ # label ) = nn.run_update( jCon, thresh, external, info, toDo, ) plot_machine(activeOT, fireOT, indiNeuronsDetailed, info, drw, toDo)
def changeExt_(): """ """ check_plt() name = "m_vs_m0" info = numParam(name) toDo = doParam()[1] info["meanExt"] = 0.04 info["timer"] = 50 jCon = nn.createjCon(info) thresh = nn.createThresh(info["sizeM"], info["threshM"], toDo["doThresh"]) mE_List = np.arange(0.04, 0.32, .02) # mE_List = np.arange(0.04, 0.36,.08) meanList = [] meanList2 = [] for i in range(len(mE_List)): external = nn.createExt(info, mE_List[i]) activeOT = nn.run_update(jCon, thresh, external, info, toDo)[1] # 1:active, 2:fire means = eva.analyzeMeanOT(activeOT, info["sizeM"]) meanList.append([mE_List[i]]) meanList2.append([mE_List[i]]) meanList[-1] += [np.mean(means[i][10:]) for i in range(2)] meanList2[-1] += [np.mean(means[i]) for i in range(2)] meanList = np.transpose(meanList) meanList2 = np.transpose(meanList2) print(meanList) name = "m_vs_m0_K%d.npy" % info["K"] np.save(name, meanList) plots.figfolder_GLOBAL = info["figfolder"] plots.mean_vs_ext(meanList)
def plain_vanilla(dur, start, swi=0): info = numParam() info['timer'] = dur #info['sizeM'][0] info['meanStartActi'] = start (drw, toDo) = doParam() toDo["switch"] = swi ### Create constant inputs to function jCon = nn.createjCon(info) external = nn.createExt(info) thresh = nn.createThresh(info["sizeM"], info["threshM"], toDo["doThresh"]) ### Updating Function (indiNeuronsDetailed, activeOT, fireOT, label) = nn.run_update( jCon, thresh, external, info, toDo, ) return activeOT
def Vanilla(): """ Iterates over whole process once according to specifications in numParam and doParam Records results. """ timestamp = [["start", time.time(), 0]] ### Specify Parameters # mode_list = ['count_up', 'static', 'permute', 'rand'] mode = "rand" name = "classic" + "_" + mode info = numParam(name) (drw, toDo) = doParam() toDo["switch"] = 0 toDo["update_mode"] = mode ### Create constant inputs to function jCon = nn.createjCon(info) external = nn.createExt(info) thresh = nn.createThresh(info["sizeM"], info["threshM"], toDo["doThresh"]) stamp(timestamp, "setup done") ### Updating Function (indiNeuronsDetailed, activeOT, fireOT, label) = nn.run_update( jCon, thresh, external, info, toDo, ) stamp(timestamp, "calculations done") ### Save Results valueFolder = plots.describe(toDo, info, 0, 1) utils.saveResults(valueFolder, indiNeuronsDetailed, activeOT, fireOT, info, toDo) stamp(timestamp, "saving done")
def hamming(): flip = 1 name = "hamming3" info = numParam() (_, toDo) = doParam() jCon = nn.createjCon(info) external = nn.createExt(info) thresh = nn.createThresh(info["sizeM"], info["threshM"], toDo["doThresh"]) info["timer"] = 50 hamm_comb = [] rand_dist = [] for i in range(10): orig = nn.createNval(info["sizeM"], info["meanStartActi"]) changed = nn.createNval(info["sizeM"], info["meanStartActi"]) dist = np.mean(abs(orig - changed)) rand_dist.append(dist) for control in range(2): orig_list = [] chang_list = [] dist_list = [] for i in range(10): rand_seed = i + 100 np.random.seed(rand_seed) random.seed(rand_seed) info["flip"] = 0 (indiNeuronsDetailed, activeOT, fireOT, label) = nn.run_update( jCon, thresh, external, info, toDo, ) orig = (transform2binary(activeOT, info["timer"])) if not control: np.random.seed(rand_seed) random.seed(rand_seed) info["flip"] = flip (indiNeuronsDetailed, activeOT, fireOT, label) = nn.run_update( jCon, thresh, external, info, toDo, ) changed = (transform2binary(activeOT, info["timer"])) dist = np.mean(abs(orig - changed), axis=1) if control: dist = np.concatenate(([rand_dist[i]], dist)) else: dist = np.concatenate(([flip / np.sum(info["sizeM"])], dist)) orig_mean = np.concatenate( ([info['meanStartActi']], np.mean(orig, axis=1))) chang_mean = np.concatenate( ([info['meanStartActi']], np.mean(changed, axis=1))) orig_list.append(orig_mean) chang_list.append(chang_mean) dist = i dist_list.append(dist) hamming = np.array(dist_list) hamm_comb.append(hamming) print(hamming.shape) print(hamm_comb)