<jupyter_start><jupyter_text>Load Conv<jupyter_code>filename = 'outarray.h5'
tables_logger.print_log(filename)
with tables.open_file(filename, mode='r') as f:
    
    tr_loss = np.array(f.root.metrics.loss)
    tr_accuracy = np.array(f.root.metrics.accuracy)
    
    tr_x_raw = np.array(f.root.inout.batch_x)
    ni, _, _, _, nn = tr_x_raw.shape
    tr_x = tr_x_raw.reshape([ni, -1, nn])
    
    tr_conv_1 = tables_logger.extract_layer_and_flatten(f.root.conv_1)
    tr_conv_2 = tables_logger.extract_layer_and_flatten(f.root.conv_2)
    tr_conv_3 = tables_logger.extract_layer_and_flatten(f.root.conv_3)
    
    tr_dense_1 = tables_logger.extract_layer_and_flatten(f.root.dense_1)
    tr_logits = tables_logger.extract_layer_and_flatten(f.root.logits)
    
    tr_y = np.array(f.root.inout.batch_y)
    tr_p = np.array(f.root.inout.probabilities)
print('tr_conv_1_W_raw', tr_conv_1['W_raw'].shape)
print('tr_conv_1_b', tr_conv_1['b'].shape)
print('tr_conv_1_dW_raw', tr_conv_1['dW_raw'].shape)
print('tr_conv_1_db', tr_conv_1['db'].shape)
print('tr_conv_1_z_raw', tr_conv_1['z_raw'].shape)

print('tr_conv_1_W', tr_conv_1['W'].shape)
print('tr_conv_1_dW', tr_conv_1['dW'].shape)
print('tr_conv_1_z', tr_conv_1['z'].shape)<jupyter_output><empty_output><jupyter_text>Loss<jupyter_code>def running_mean(x, n):
    return np.array([ np.mean(x[max(i-n+1, 0): i+1]) for i in range(len(x))])
#
#   Plot Loss, Accuracy
#
fig, ax = plt.subplots(figsize=[12,6])
ax.scatter(range(len(tr_loss)), tr_loss, label='Mini-Batch loss', alpha=.5, marker='.', s=1)
ax.plot(running_mean(tr_loss, 100), label='Mini-Batch loss', alpha=1, color='orange')

ax.scatter(range(len(tr_accuracy)), tr_accuracy, label='Mini-Batch accuracy', alpha=.5, marker='.', s=1, color='red')

ax.legend()
ax.grid()

fig.tight_layout()<jupyter_output><empty_output><jupyter_text>Inputs<jupyter_code>tr_x.shape
es = 30 * 5120
plotann.show_layer_activations(tr_x, epoch_size=es, activation_function=None,
                               title_prefix='Input', color=(.7,.7,.7,1), figsize=[16,6])
plotann.show_neurons_activations(tr_x, epoch_size=es, activation_function=None, neurons=range(tr_x.shape[-1]),
                                 title_prefix='Input', color=(.7,.7,.7,1))<jupyter_output><empty_output><jupyter_text>Conv 1<jupyter_code>plotann.show_neurons_weights(tr_conv_1['W'], tr_conv_1['dW'], neurons=range(20),
                            title_prefix='Conv_1', color='red', figsize=[16,4])
plotann.show_biases(tr_conv_1['b']+1e-6, tr_conv_1['db'], title_prefix='Biases_1', color='red', figsize=[16,4])
plotann.show_layer_summary(tr_conv_1['W'], tr_conv_1['dW'],
                           title_prefix='Hidden_1', color='red', figsize=[16,5])<jupyter_output><empty_output><jupyter_text>---<jupyter_code>tr_conv_1['z'].shape
es = 10 * 5120  # epoch_size
act_fun = 'relu'
plotann.show_layer_activations(tr_conv_1['z'], epoch_size=es, activation_function=act_fun,
                               title_prefix='Conv_1', color=(1,0,0,1), figsize=[16,6])
plotann.show_neurons_activations(tr_conv_1['z'], epoch_size=es, activation_function=act_fun, neurons=range(10),
                                 title_prefix='Conv_1', color=(1,0,0,1))<jupyter_output><empty_output><jupyter_text>Conv 2<jupyter_code>plotann.show_neurons_weights(tr_conv_2['W'], tr_conv_2['dW'], neurons=range(20),
                            title_prefix='Conv_2', color='orange', figsize=[16,4])
plotann.show_biases(tr_conv_2['b']+1e-6, tr_conv_2['db'], title_prefix='Conv_2', color='orange', figsize=[16,4])
plotann.show_layer_summary(tr_conv_2['W'], tr_conv_2['dW'],
                           title_prefix='Conv_2', color='orange', figsize=[16,5])<jupyter_output><empty_output><jupyter_text>---<jupyter_code>tr_conv_2['z'].shape
es = 10 * 1280  # epoch_size
act_fun = 'relu'
plotann.show_layer_activations(tr_conv_2['z'], epoch_size=es, activation_function=act_fun,
                               title_prefix='Conv_2', color=(1,.5,.25,1), figsize=[16,6])
plotann.show_neurons_activations(tr_conv_2['z'], epoch_size=es, activation_function=act_fun, neurons=range(10),
                                 title_prefix='Conv_2', color=(1,.5,.25,1))<jupyter_output><empty_output><jupyter_text>Conv 3<jupyter_code>plotann.show_neurons_weights(tr_conv_3['W'], tr_conv_3['dW'], neurons=range(20),
                            title_prefix='Conv_3', color='gold', figsize=[16,4])
plotann.show_biases(tr_conv_3['b']+1e-6, tr_conv_3['db'], title_prefix='Conv_3', color='gold', figsize=[16,4])
plotann.show_layer_summary(tr_conv_3['W'], tr_conv_3['dW'],
                           title_prefix='Conv_3', color='gold', figsize=[16,5])<jupyter_output><empty_output><jupyter_text>---<jupyter_code>tr_conv_3['z'].shape
es = 10 * 320  # epoch_size
act_fun = 'relu'
plotann.show_layer_activations(tr_conv_3['z'], epoch_size=es, activation_function=act_fun,
                               title_prefix='Conv_3', color=(1,.75,0,1), figsize=[16,6])
plotann.show_neurons_activations(tr_conv_3['z'], epoch_size=es, activation_function=act_fun, neurons=range(10),
                                 title_prefix='Conv_3', color=(1,.75,0,1))<jupyter_output><empty_output><jupyter_text>Dense 1<jupyter_code>plotann.show_neurons_weights(tr_dense_1['W'], tr_dense_1['dW'], neurons=range(3),
                             title_prefix='Dense_1', color='lightblue', figsize=[16,4])
plotann.show_biases(tr_dense_1['b']+1e-6, tr_dense_1['db'], title_prefix='Dense_1', color='lightblue', figsize=[16,4])
plotann.show_layer_summary(tr_dense_1['W'], tr_dense_1['dW'], title_prefix='Dense_1', color='lightblue', figsize=[16,5])<jupyter_output><empty_output><jupyter_text>---<jupyter_code>tr_dense_1['z'].shape
es = 10 * 5
act_fun = 'relu'
plotann.show_layer_activations(tr_dense_1['z'], epoch_size=es, activation_function=act_fun,
                               title_prefix='Dense_1', color=(.7,.7,1,1), figsize=[16,6])
plotann.show_neurons_activations(tr_dense_1['z'], epoch_size=es, activation_function=act_fun,
                                 neurons=range(10), title_prefix='Dense_1', color=(.7,.7,1,1))<jupyter_output><empty_output><jupyter_text>Logits<jupyter_code>plotann.show_neurons_weights(tr_logits['W'], tr_logits['dW'], neurons=range(tr_logits['W'].shape[-1]),
                            title_prefix='Logits', color='lightblue', figsize=[16,4])
plotann.show_biases(tr_logits['b']+1e-6, tr_logits['db'], title_prefix='Output_Biases', color='lightblue', figsize=[16,4])
plotann.show_layer_summary(tr_logits['W'], tr_logits['dW'], title_prefix='Output', color='lightblue', figsize=[16,5])<jupyter_output><empty_output><jupyter_text>---<jupyter_code>tr_logits['z'].shape
es = 10 * 5
act_fun = 'relu'
plotann.show_layer_activations(tr_logits['z'], epoch_size=es, activation_function=act_fun,
                               title_prefix='Logits', color=(.7,.7,1,1), figsize=[16,6])
plotann.show_neurons_activations(tr_logits['z'], epoch_size=es, activation_function=act_fun,
                                 neurons=range(tr_logits['z'].shape[-1]), title_prefix='Logits', color=(.7,.7,1,1))<jupyter_output><empty_output><jupyter_text>Probabilities<jupyter_code>tr_p.shape
es = 10 * 5
plotann.show_layer_activations(tr_p, epoch_size=es, activation_function=None,
                               title_prefix='Probabilities', color=(0,0,1,1), figsize=[16,6])
plotann.show_neurons_activations(tr_p, epoch_size=es, activation_function=None, neurons=range(tr_p.shape[-1]),
                                 title_prefix='Probabilities', color=(0,0,1,1))<jupyter_output><empty_output><jupyter_text>Targets<jupyter_code>tr_y.shape
es = 10 * 5
plotann.show_layer_activations(tr_y, epoch_size=es, activation_function=None,
                               title_prefix='Target', color=(.7,.7,.7,1), figsize=[16,6])
plotann.show_neurons_activations(tr_y, epoch_size=es, activation_function=None, neurons=range(tr_y.shape[-1]),
                                 title_prefix='Target', color=(.7,.7,.7,1))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16776684518620003, 'fraction_numerical': 0.037613650516876325, 'mean_word_length': 5.037593984962406, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '321763', 'license': 'MIT', 'n_tokens_mistral': 3181, 'n_tokens_neox': 3069, 'n_words': 305, 'path': 'DebugNN/PlotCNN.ipynb', 'repo_name': 'marcinbogdanski/ai-sketchpad', 'size': '8029'}