def make_resp(filt, model, quenched, K, mgs, tag, COR, ncor, n_trial=1, NOISE=True): P = COR[0] CNS = COR[1] C1 = COR[2] C2 = COR[3] print(P.shape) print(CNS.shape) print(C1.shape) print(C2.shape) GVnn = MGSM.MGSM_gnn(filt, CNS, C1, C2, P, model) return GVnn
def make_att_resp(filt1, filt2, model, quenched, K, mgs, tag, COR, ncor, qcor, fcor, n_trial=1): P = COR[0] CNS = COR[1] C1 = COR[2] C2 = COR[3] NCNS = ncor[0] NC1 = ncor[1] NC2 = ncor[2] QCNS = qcor[0] QC1 = qcor[1] QC2 = qcor[2] FCNS = fcor[0] FC1 = fcor[1] FC2 = fcor[2] fullcor = ncor[3] fullqcor = qcor[3] print(CNS.shape) print(C1.shape) #make sure everything is the right type assert model in ("ours", "coen_cagli") assert quenched in (True, False) assert type(ncor) == list GV = [] GVnn = [] #run it for each value of k SP = [] SPnn = [] for k in K: print(k) GV.append( MGSM.MGSM_att_g(filt1, filt2, [CNS, C1, C2], [NCNS * (k * k), NC1 * (k * k), NC2 * (k * k)], [QCNS, QC1, QC2], [FCNS, FC1, FC2], P)) GVnn.append(MGSM.MGSM_gnn(filt2, [CNS, C1, C2], P)) SP.append( MGSM.get_att_CC_seg_weight(filt1, filt2, CNS, C1, C2, NCNS * (k * k), NC1 * (k * k), NC2 * (k * k), QCNS, QC1, QC2, FCNS, FC1, FC2, P)) SPnn.append(MGSM.get_CC_seg_weight(filt2, CNS, C1, C2, P)) GV = np.concatenate(GV) GVnn = np.concatenate(GVnn) SP = np.concatenate(SP) SPnn = np.concatenate(SPnn) np.savetxt(tag + "_noisy.csv", GV) np.savetxt(tag + "_clean.csv", GVnn) np.savetxt(tag + "_SP_noisy.csv", SP) np.savetxt(tag + "_SP_clean.csv", SPnn) return GV, GVnn
def make_resp(filt, model, quenched, K, mgs, tag, COR, ncor, n_trial=1): P = COR[0] CNS = COR[1] C1 = COR[2] C2 = COR[3] NCNS = ncor[0] NC1 = ncor[1] NC2 = ncor[2] fullcor = ncor[3] print(CNS.shape) print(C1.shape) #make sure everything is the right type assert model in ("ours", "coen_cagli") assert quenched in (True, False) assert type(ncor) == list GV = [] GVnn = [] #generate samples for each filter set if quenched: nftemp = np.tile(filt, [n_trial, 1, 1]) noise = np.reshape( np.random.multivariate_normal(np.zeros(np.prod(nftemp.shape[1:])), fullcor, n_trial * filt.shape[0]), tuple([n_trial * filt.shape[0]]) + filt.shape[1:]) nftemp += noise else: nftemp = filt #run it for each value of k SP = [] SPnn = [] for k in K: print(k) print(nftemp.shape) GV.append( MGSM.MGSM_g(nftemp, [CNS, C1, C2], [NCNS * (k * k), NC1 * (k * k), NC2 * (k * k)], P)) GVnn.append(MGSM.MGSM_gnn(filt, [CNS, C1, C2], P)) if model == "ours": SP.append( MGSM.get_noisy_seg_weight(filt, CNS, C1, C2, NCNS * (k * k), NC1 * (k * k), NC2 * (k * k), P)) SPnn.append(MGSM.get_seg_weight(filt, CNS, C1, C2, P)) elif model == "coen_cagli": SP.append( MGSM.get_noisy_CC_seg_weight(filt, CNS, C1, C2, NCNS * (k * k), NC1 * (k * k), NC2 * (k * k), P)) SPnn.append(MGSM.get_CC_seg_weight(filt, CNS, C1, C2, P)) GV = np.concatenate(GV) GVnn = np.concatenate(GVnn) SP = np.concatenate(SP) SPnn = np.concatenate(SPnn) np.savetxt(tag + "_noisy.csv", GV) np.savetxt(tag + "_clean.csv", GVnn) np.savetxt(tag + "_SP_noisy.csv", SP) np.savetxt(tag + "_SP_clean.csv", SPnn) return GV, GVnn