<jupyter_start><jupyter_text>This notebook plots filter match results for different initializations (Supplementary Fig. 5a)<jupyter_code>import os
import numpy as np
from six.moves import cPickle
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Plot CNN-deep's motif match to JASPAR for different initializations for Relu and Exponential activations<jupyter_code>initializations = ['glorot_normal', 'glorot_uniform', 'he_normal', 'he_uniform', 'lecun_normal', 'lecun_uniform']

initial_names = ['Glorot-normal', 'Glorot-uniform', 'He-normal', 'He-uniform', 'LeCun-normal', 'LeCun-uniform']

activations = ['relu', 'exp']
activation_names = ['Relu', 'Exponential']


results_path = os.path.join('../../results', 'initialization')
file_path = os.path.join(results_path, 'intialization_filter_results.pickle')
with open(file_path, 'rb') as f:
    results = cPickle.load(f)
    
fig = plt.figure(figsize=(7,9))
ax = plt.subplot(3,1,1)
vals = []
for thresh in initializations:
    vals.append(results['relu'][thresh]['match_fraction'])
ax.boxplot(vals);
ax.set_xticklabels([])
plt.ylabel('Match fraction', fontsize=14)
plt.yticks([0, 0.25, 0.5, 0.75, 1.0], fontsize=14)
plt.ylim([-.04, 1.04])
ax.yaxis.tick_right()
ax2 = ax.twinx()
ax2.set_yticks([])
ax2.set_ylabel('CNN-deep (Relu)', fontsize=14)

ax = plt.subplot(3,1,2)
vals = []
for thresh in initializations:
    vals.append(results['exp'][thresh]['match_fraction'])
ax.boxplot(vals);
ax.set_xticklabels([])
plt.ylabel('Match fraction', fontsize=14)
plt.ylim([-.04, 1.04])
plt.yticks([0, 0.25, 0.5, 0.75, 1.0], fontsize=14)
ax.set_xticklabels([])

ax.yaxis.tick_right()
ax2 = ax.twinx()
ax2.set_yticks([])
ax2.set_ylabel('CNN-deep (Exp)', fontsize=14)


results_path = '../../results'

file_path = os.path.join(results_path, 'initialization_nobn', 'intialization_filter_results.pickle')
with open(file_path, 'rb') as f:
    results = cPickle.load(f)
    
ax = plt.subplot(3,1,3)
vals = []
for thresh in initializations:
    vals.append(results['exp'][thresh]['match_fraction'])
ax.boxplot(vals);
ax.set_xticklabels([])
plt.ylabel('Match fraction', fontsize=14)
plt.yticks([0, 0.25, 0.5, 0.75, 1.0], fontsize=14)
plt.ylim([-.04, 1.04])
plt.xticks(range(1,len(initial_names)+1), initial_names, fontsize=14, rotation=45, ha="right");
ax.yaxis.tick_right()
ax2 = ax.twinx()
ax2.set_yticks([])
ax2.set_ylabel('CNN-deep (Exp)\nNo batch-norm', fontsize=14)

outfile = os.path.join(results_path, 'filter_thresh.pdf')
fig.savefig(outfile, format='pdf', dpi=200, bbox_inches='tight')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18013856812933027, 'fraction_numerical': 0.03695150115473441, 'mean_word_length': 6.425714285714286, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '640914', 'license': 'MIT', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1018, 'n_words': 185, 'path': 'code/controls/initialization_step4_visualize_filter_match.ipynb', 'repo_name': 'p-koo/exponential_activations', 'size': '2598'}