print('completed %d: mean %d and se %d' % (d, mean, se)) pickle.dump( instance_list, open(os.path.join(data_dir, "static_" + str(d) + ".p"), "wb")) except: print('error') pool.close() pool.join() # ORACLE if 'oracle' in arguments: np.random.seed(43) instance_list = [ XY_ORACLE(X, theta_star, delta, Z) for i in range(count) ] seed_list = list(np.random.randint(0, 100000, count)) parallel_sim = functools.partial(sim_wrapper, instance_list, seed_list) pool = multiprocess.Pool(5) num_list = list(range(count)) instance_list = [] for instance in pool.imap_unordered(parallel_sim, num_list): try: instance_list.append(instance) print('Finished ORACLE Instance') sample_complexity = np.array( [instance.N for instance in instance_list]) mean = np.mean(sample_complexity) se = np.std(sample_complexity) / np.sqrt(count)
print('completed %d: mean %d and se %d' % (d, mean, se)) pickle.dump( instance_list, open(os.path.join(data_dir, "static_" + str(n) + ".p"), "wb")) except: print('error') pool.close() pool.join() # ORACLE if 'oracle' in arguments: np.random.seed(43) instance_list = [ XY_ORACLE(X, theta_star, delta) for X, theta_star in zip(X_set, theta_star_set) ] seed_list = list(np.random.randint(0, 100000, count)) parallel_sim = functools.partial(sim_wrapper, instance_list, seed_list) pool = multiprocess.Pool(pool_num) num_list = list(range(count)) instance_list = [] for instance in pool.imap_unordered(parallel_sim, num_list): try: instance_list.append(instance) print('Finished Oracle Instance') sample_complexity = np.array( [instance.N for instance in instance_list]) mean = np.mean(sample_complexity)
# print('completed %d: mean %d and se %d' % (d, mean, se)) # # f = open( # os.path.join(data_dir, "static_" + str(d) + ".p"), "wb") # pickle.dump(instance_list, f) # f.close() # except: # print('error') # # pool.close() # pool.join() # # ORACLE if 'oracle' in arguments: np.random.seed(43) instance_list = [XY_ORACLE(X, theta_star, delta) for i in range(count)] seed_list = list(np.random.randint(0, 100000, count)) parallel_sim = functools.partial(sim_wrapper, instance_list, seed_list) pool = multiprocess.Pool(pool_num) num_list = list(range(count)) instance_list = [] for instance in pool.imap_unordered(parallel_sim, num_list): try: instance_list.append(instance) print('Finished Oracle Instance') sample_complexity = np.array( [instance.N for instance in instance_list]) mean = np.mean(sample_complexity) se = np.std(sample_complexity) / np.sqrt(count)
mean = np.mean(sample_complexity) se = np.std(sample_complexity)/np.sqrt(count) pickle.dump((mean, se), open(os.path.join(data_dir, "static_" + str(n) + "_data.p"), "wb")) print('completed %d: mean %d and se %d' % (n, mean, se)) pickle.dump(instance_list, open(os.path.join(data_dir, "static_" + str(n) + ".p"), "wb")) except: print('error') pool.close() pool.join() # ORACLE if 'oracle' in arguments: np.random.seed(43) instance_list = [XY_ORACLE(X, theta_star, delta) for X, theta_star in zip(X_set, theta_star_set)] seed_list = list(np.random.randint(0, 100000, count)) parallel_sim = functools.partial(sim_wrapper, instance_list, seed_list) pool = multiprocess.Pool(pool_num) num_list = list(range(count)) instance_list = [] for instance in pool.imap_unordered(parallel_sim, num_list): try: instance_list.append(instance) print('Finished ORACLE Instance') sample_complexity = np.array([instance.N for instance in instance_list]) mean = np.mean(sample_complexity) se = np.std(sample_complexity)/np.sqrt(count) pickle.dump((mean, se), open(os.path.join(data_dir, "oracle_" + str(n) + "_data.p"), "wb")) print('completed %d: mean %d and se %d' % (n, mean, se))