jitonic = None tau_cla = 50000 namelist = ['raw', 'homhots'] namelist = ['raw', 'hots', 'homhots'] for name in namelist: f_name = f'{record_path}{timestr}_LR_results_{name}_{nbclust}_36_40_{ds_ev}.pkl' if os.path.isfile(f_name): with open(f_name, 'rb') as file: likelihood, true_target, time_scale = pickle.load(file) else: print(f'LR fit for {name}...') model, loss = fit_data(name,timestr,record_path,filt,tau,R,nbclust,sigma,homeinv,jitter,dataset,nb_train, ds_ev,learning_rate,num_epochs,betas,tau_cla,jitonic=jitonic,num_workers=num_workers,verbose=False) print(f'prediction for {name}...') likelihood, true_target, time_scale = predict_data(model,name,timestr,record_path,filt,tau,R,nbclust,sigma, homeinv, jitter,dataset,nb_test,ds_ev,tau_cla,jitonic=jitonic,num_workers=num_workers, verbose=False) with open(f_name, 'wb') as file: pickle.dump([likelihood, true_target, time_scale], file, pickle.HIGHEST_PROTOCOL) timesteps = np.arange(500,100000,100) nb_classes = 10 results = [timesteps] for namnum, name in enumerate(namelist): f_name = f'{record_path}{timestr}_LR_results_{name}_{nbclust}_{nb_train}_{nb_test}_{ds_ev}_timescale.pkl' with open(f_name, 'rb') as file: likelihood, true_target, time_scale = pickle.load(file) y_true = np.zeros([len(true_target)])
beta1, beta2 = 0.9, 0.999 betas = (beta1, beta2) num_epochs = 2 ** 5 + 1 #num_epochs = 2 ** 9 + 1 print(f'number of epochs: {num_epochs}') #______________________________________________ timestr = '2021-02-16' record_path = '../Records/EXP_03_NMNIST/models/' for name in ['raw','hots','homhots']: tic() learn_set, nb_pola, name_net = get_loader(name, record_path, nb_train, True, filt, tau, nblay, nbclust, sigma, homeinv, jitter, timestr) model, loss = fit_data(name_net, learn_set, nb_train, nb_pola, learning_rate, num_epochs, betas, verbose=True) test_set, nb_pola, name_net = get_loader(name, record_path, nb_test, False, filt, tau, nblay, nbclust, sigma, homeinv, jitter, timestr) pred_target, true_target = predict_data(test_set, model, nb_test) mean_acc, online_acc = classification_results(pred_target, true_target, nb_test) toc() print(f'Classification performance for {name}: {mean_acc}') homhots_jit_s = [] hots_jit_s = [] homhots_jit_t = [] hots_jit_t = [] for name in ['homhots', 'hots']: learn_set, nb_pola, name_net = get_loader(name, record_path, nb_train, True, filt, tau, nblay, nbclust, sigma, homeinv, jitter, timestr) model, loss = fit_data(name_net, learn_set, nb_train, nb_pola, learning_rate, num_epochs, betas, verbose=True) for j_s in jit_s: jitonic = [None,j_s] test_set, nb_pola, name_net = get_loader(name, record_path, nb_test, False, filt, tau, nblay, nbclust, sigma, homeinv, jitter, timestr, jitonic = jitonic) pred_target, true_target = predict_data(test_set, model, nb_test)
print(f'get testing set for {name}...') test_set, nb_pola, name_net = get_loader(name, record_path, nb_test, False, filt, tau, nbclust, sigma, homeinv, jitter, timestr, dataset, R, ds_ev=ds_ev_output) print(f'prediction for {name}...') pred_target, true_target = predict_data(test_set, model, nb_test, num_workers=num_workers) mean_acc, online_acc = classification_results(pred_target, true_target, nb_test) print(f'Classification performance for {name}: {mean_acc}') results.append([pred_target, true_target, mean_acc, online_acc]) path = '../Records/EXP_05_POKERDVS/' f_name = f'{path}{timestr}_LR_results_{nbclust}_{nb_train}_{nb_test}_{ds_ev_output}.pkl' with open(f_name, 'wb') as file: pickle.dump([results], file, pickle.HIGHEST_PROTOCOL)
jitonic=jitonic, subset_size=nb_train, num_workers=num_workers, verbose=False) ds_ev = ds_ev_test print(f'prediction for {name}...') likelihood, true_target, time_scale = predict_data( model, name, timestr, path, filt, tau, R, nbclust, sigma, homeinv, jitter, dataset, nb_test, ds_ev, tau_cla, sample_space=sample_space, jitonic=jitonic, subset_size=nb_test, num_workers=num_workers, verbose=False) with open(f_name, 'wb') as file: pickle.dump([likelihood, true_target, time_scale], file, pickle.HIGHEST_PROTOCOL) #return likelihood, true_target, time_scale