pp(sys.version_info, 0) # PARAMETERS #### learning = False # Decide whether to run the sparse coding algorithm classification = True # Run classification resume = True ts_size = 13 # size of the time surfaces tau = 5000 # time constant for the construction of time surfaces polarities = 1 # number of polarities that we will use in the dataset (1 because polarities are not informative in the cards dataset) if resume: output_path = "../../../results/main_nmnist.py.d1062928/" else: output_path = create_output_path() dtr = None dte = None #pp("rank: ", comm.rank) to_scatter_train = None to_scatter_test = None if comm.rank == 0: #fh = tb.open_file("../datasets/nmnist_small.h5") fh = tb.open_file("../../../datasets/nmnist_one_saccade.h5") #fh = tb.open_file("../datasets/nmnist.h5") dtr = [d.read().astype(np.int32) for d in fh.root.train] dte = [d.read().astype(np.int32) for d in fh.root.test] to_scatter_train = [dtr[i::nprocs] for i in range(nprocs)]
params = {} exec(compile(open(param_fname).read(), param_fname, 'exec'), params) # Extract some parameters N = params.get('N', 5000) # no. of datapoint in the testset size = params.get('size', 5) # width / height of bars images p_bar = params.get('p_bar', 1. / size) # prob. for a bar to be active D = params.get('D', size**2) # observed dimensionality H = params.get('H', 2 * size) # latent dimensionality model = params['model'] # the actual generative model # Ground truth parameters -- only used for generation params_gt = params.get('params_gt') # Ground truth param # Create output path output_path = create_output_path(param_fname) # Disgnostic output pprint("=" * 40) pprint(" Running bars experiment (%d parallel processes)" % comm.size) pprint(" size of training set: %d" % N) pprint(" size of bars images: %d x %d" % (size, size)) pprint(" number of hiddens: %d" % H) pprint(" saving results to: %s" % output_path) pprint() # Generate bars data my_data = model.generate_data(params_gt, N // comm.size) # Configure DataLogger print_list = ('T', 'Q', 'pi', 'sigma', 'N', 'MAE')
# Extract some parameters N = params.get('N', 5000) # no. of datapoint in the testset N_train = int(0.9 * N) N_test = N - N_train size = params.get('size', 5) # width / height of bars images p_bar = params.get('p_bar', 1. / size) # prob. for a bar to be active D = params.get('D', size**2) # observed dimensionality H = params.get('H', 2 * size) # latent dimensionality model = params['model'] # the actual generative model model_str = model.__class__.__name__ # Ground truth parameters -- only used for generation params_gt = params.get('params_gt') # Ground truth param # Create output path output_path = create_output_path('learning-and-inference-' + param_fname) # Disgnostic output pprint("=" * 40) pprint(" Running bars experiment (%d parallel processes)" % comm.size) pprint(" size of training set: %d" % N) pprint(" size of bars images: %d x %d" % (size, size)) pprint(" number of hiddens: %d" % H) pprint(" saving results to: %s" % output_path) pprint() my_data = model.generate_data(params_gt, N_train // comm.size) my_test_data = model.generate_data(params_gt, N_test // comm.size) # Configure DataLogger store_list = ('*')