nsat.run_c_nsat(fname_train) print(('Run took {0} seconds'.format(time.time() - t0))) for j in range(setup.ncores): #train->test shutil.copy(exp_name + '/_shared_mem_core_{0}.dat'.format(j), exp_name_test + '/_wgt_table_core_{0}.dat'.format(j)) #train->train shutil.copy(exp_name + '/_shared_mem_core_{0}.dat'.format(j), exp_name + '/_wgt_table_core_{0}.dat'.format(j)) if test_every > 0: if i % test_every == test_every - 1: nsat.run_c_nsat(fname_test) acc, slout = test_accuracy(c_nsat_reader_test, targets=targets_classify[:N_test], pop=pop_out, sim_ticks=sim_ticks_test, duration=t_sample_test) pip.append([i, acc]) print(exp_name) print(pip) try: import experimentTools as et d = et.mksavedir(pre='Results_Scripts/') et.save(pip, 'pip.pkl') et.annotate('res', text=str(pip)) except ImportError: print('saving disabled due to missing experiment tools')
acc_hist.append([i, res]) print res if res>last_perf: last_perf = res #bestM = read_allparamters_dual(context) # # Necessary otherwise will only train on 1000 images total. # # ############# # if n_epochs == 0 and test_every>0: #Test only # print 'Test only' # res = run_classify(context, labels_test) # acc_hist.append([0, res]) # print res # M = process_parameters_auto(context) d=et.mksavedir() et.globaldata.context = context et.save() et.save(context, 'context.pkl') et.save(sys.argv, 'sysargv.pkl') et.save(M,'M.pkl') et.save(spkcnt,'spkcnt.pkl') et.save(bestM,'bestM.pkl') et.save(acc_hist, 'acc_hist.pkl') et.annotate('res',text=str(acc_hist)) textannotate('last_res',text=str(acc_hist)) textannotate('last_dir',text=d) # # #
def update_output_weights(output_weights): output_mtx = fio.mtx_file_to_matrix('inputs/{}/train/fwmat_ho.mtx'.format( context['directory'])) output_mtx = output_mtx[200:, :].flatten() output_weights.append(output_mtx) return output_weights if __name__ == '__main__': try: last_perf = (-1.0, -1.0) new_test_data = args.gen_data save = True et.mksavedir() et.globaldata.context = context start_epoch = 0 acc_hist = [] snr_hist = [] weight_stats = {} output_weights = [] spkcnt = [None for i in range(context['n_epochs'])] if args.resume is not '': if args.resume[-1] is not '/': args.resume += '/' print 'Loading previous run from {}'.format(args.resume) et.globaldata.directory = args.resume M = et.load('M.pkl')