def get_input_gen(config, retina): inputmethod = config['Retina']['inputmethod'] if inputmethod == 'read': print('Generating input files') with Timer('input generation'): gi.gen_input(config) return None else: print('Using input generating function') return RetinaInputProcessor(config, retina)
def get_input_gen(config, retina): ''' Depending on configuration input can either be created in advance and read from file or generated during simulation by a generator object. ''' inputmethod = config['Retina']['inputmethod'] if inputmethod == 'read': print('Generating input files') with Timer('input generation'): gi.gen_input(config) return None else: print('Using input generating function') return RetinaInputProcessor(config, retina)
def get_input_gen(config): ''' Depending on configuration input can either be created in advance and read from file or generated during simulation by a generator object. ''' inputmethod = config['Retina']['inputmethod'] if inputmethod == 'read': print('Generating input files') with Timer('input generation'): gi.gen_input(config) return None else: print('Using input generating function') return RetinaInputGenerator(config)
sys.stdout = Tee(script_output_filename(tmpdir)) #algs = ['fftw', 'sfft2-mit', 'sfft1-mit', 'aafft', 'sfft1-eth', 'sfft2-eth'] algs = ['fftw', 'sfft2-mit', 'sfft1-mit', 'aafft'] #algs = ['sfft2-mit'] for snr in snr_db_vals: print 'snr = {} db ({:.6e})'.format(snr, db_to_ratio(snr)) print ' generating input data ...' input_filename = [] for instance in range(1, num_instances + 1): print ' instance {}'.format(instance) dataf = data_filename_snr(tmpdir, n, k, snr, instance) gen_input(n, k, dataf, seed=random.randint(0, 2000000000), stats_file=data_stats_filename_snr(tmpdir, n, k, snr, instance), noise_variance=snr_db_to_noise_variance(snr, n, k), randomize_phase=True) input_filename.append(dataf) print ' writing index file ...' indexf = index_filename_snr(tmpdir, n, k, snr) write_index_file(indexf, input_filename) for alg in algs: resultsf = results_filename_snr(tmpdir, alg, n, k, snr) print ' algorithm: {}'.format(alg) r = run_experiment(n, k, indexf, alg, l0_eps, num_trials, seed=random.randint(0, 2000000000), output_file=resultsf) rel_l2_l2 = compute_relative_l2_l2_errors(r) ne = 0 for err in rel_l2_l2: if err > relative_l2_l2_error_threshold: ne += 1
sys.stdout = Tee(script_output_filename(tmpdir)) algs = ['fftw', 'sfft2-eth', 'sfft2-mit', 'sfft1-eth', 'sfft1-mit', 'aafft'] #algs = ['sfft3-eth', 'sfft2-eth'] for k in kvals: print 'k = {}'.format(k) print ' generating input data ...' input_filename = [] for instance in range(1, num_instances + 1): print ' instance {}'.format(instance) dataf = data_filename(tmpdir, n, k, instance) gen_input(n, k, dataf, random.randint(0, 2000000000), stats_file=data_stats_filename(tmpdir, n, k, instance)) input_filename.append(dataf) print ' writing index file ...' indexf = index_filename(tmpdir, n, k) write_index_file(indexf, input_filename) for alg in algs: resultsf = results_filename(tmpdir, alg, n, k) print ' algorithm: {}'.format(alg) r = run_experiment(n, k, indexf, alg, l0_eps, num_trials, resultsf) ne = num_l0_errors(r) if ne > 0: print ' {} L0-errors occurred.'.format(ne) for f in input_filename: os.remove(f)
random.seed(7524019) plot = False sys.stdout = Tee(script_output_filename(tmpdir)) # algs = ['fftw', 'sfft2-eth', 'sfft2-mit', 'sfft1-eth', 'sfft1-mit', 'aafft'] algs = ["sfft3-eth"] for k in kvals: print "k = {}".format(k) print " generating input data ..." input_filename = [] for instance in range(1, num_instances + 1): print " instance {}".format(instance) dataf = data_filename(tmpdir, n, k, instance) gen_input(n, k, dataf, random.randint(0, 2000000000), stats_file=data_stats_filename(tmpdir, n, k, instance)) input_filename.append(dataf) print " writing index file ..." indexf = index_filename(tmpdir, n, k) write_index_file(indexf, input_filename) for alg in algs: resultsf = results_filename(tmpdir, alg, n, k) print " algorithm: {}".format(alg) r = run_experiment(n, k, indexf, alg, l0_eps, num_trials, resultsf) ne = num_l0_errors(r) if ne > 0: print " {} L0-errors occurred.".format(ne) for f in input_filename: os.remove(f) time_results = {}