<jupyter_start><jupyter_text>Run ABC (Reproducibility)run the script run_abc.py to generate all the necessary data from the ABC-SMC sampler. Alternatively one can directly discover and tune the notebook: abc_smc.ipynb.Will compute and store the following files * smcabc_posterior_5gen.npy - posterior samples* smcabc_posterior_5gen_time.npy - elapsed time* smcabc_posterior_5gen_res.npy - posterior object<jupyter_code>%run run_abc.py<jupyter_output><empty_output><jupyter_text>Run SNPE-C (reproducibility)And finally run the SNPE (sbi package) script.Generating the following files* SBI_10_10gen_large.npy - sbi posterior object* SBI_10_10gen_large_sample.npy ' posterior samples* SBI_10_10gen_large_sample_times.npy - elapsed times<jupyter_code>sbi_experiment()<jupyter_output><empty_output><jupyter_text>Custom SNPE (Testing)Similar to BNN we supply the cell for a more custom run of the SNPE call, however, here we only easly allow to tune the number of runs and generations (rounds in paper).<jupyter_code>sbi_post, sbi_times, snpe_posteriors = run_snpe(total_runs=1, num_generation=1, seed=0)
ID = 'data'
np.save(f'{ID}/sbi_{ID}_post', sbi_post)
np.save(f'{ID}/sbi_{ID}_time', sbi_time)
# Take the DirectPosterior to get the NN
test = snpe_posteriors[0]
count_parameters(test.net)<jupyter_output><empty_output><jupyter_text>Run BNN (Reproducibility)Similar to above, the script run_bnn.py will generate all the files from the experiments regarding the BCNN approach explored in the paper. The following files are producedposterior samples from 5 classed (bins), repeated 5 times, a 8 step iteration, with 0.05 threshold. With the time elapsed.* bnn_res_5_5round_8gen_theta_thresh.npy * bnn_res_5_5round_8gen_time_thresh.npyposterior samples from 4 bins, repeated 5 times, a 8 step iteration, with 0.05 threshold. With the time elapsed.* bnn_res_4_5round_8gen_theta_thresh.npy - posterior samples from 4 bins, repeated 5 times, a 8 step iteration, with 0.05 threshold.* bnn_res_4_5round_8gen_time_thresh.npy - time for aboveposterior samples from 3 bins, repeated 5 times, a 8 step iteration, with 0.05 threshold. With the time elapsed.* bnn_res_3_5round_8gen_theta_thresh.npy - posterior samples from 3 bins, repeated 5 times, a 8 step iteration, with 0.05 threshold.* bnn_res_3_5round_8gen_time_thresh.npy - time for aboveposterior samples from 5 bins, repeated 5 times, a 8 step iteration, with no threshold. With the time elapsed.* bnn_res_5_5round_8gen_theta.npy - posterior samples from 5 bins, repeated 5 times, a 8 step iteration, with no threshold.* bnn_res_5_5round_8gen_theta.npy - time for above<jupyter_code>import tensorflow as tf

#in case CUDA is causing problems...
tf.config.set_visible_devices([], 'GPU')
bnn_experiment()<jupyter_output><empty_output><jupyter_text>Custom BNN (Testing)If one preferbly runs only specific hyperparameters not used in the paper one can run the following cell, and potentially tune * num_bins* threshand the running time can be reduced by decreasing * max_rounds (from original 5)* max_gen (from original 8)<jupyter_code>bnn_res = run_bnn(max_rounds=1,max_gen=3,Ndata=1000,seed=0, multi_dim=True, num_bins=5,thresh=0.05, verbose=True)
bcnn_post = bnn_res['theta']
bcnn_time = bnn_res['time']
ID = 'data'
np.save(f'{ID}/bcnn_{ID}_post', bcnn_post)
np.save(f'{ID}/bcnn_{ID}_time', bcnn_time)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08093685146753632, 'fraction_numerical': 0.027275422472576343, 'mean_word_length': 6.668181818181818, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '96266', 'license': 'MIT', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1128, 'n_words': 348, 'path': 'LV/experiments.ipynb', 'repo_name': 'Wrede/BNN-LFI', 'size': '3373'}