<jupyter_start><jupyter_text>Load the CSV file, save it as npy file and then visualize the brain slices<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
from numpy import genfromtxt
import numpy as np
import tensorflow as tf
my_data = genfromtxt('5710.csv', delimiter=',')
my_data.shape
reshaped = np.reshape(my_data,(640,64,64,8))
reshaped.shape
np.save('05710-image.npy', reshaped)
for j in range(4):
    for i in range(8): 
        plt.show(plt.imshow(reshaped[j,:,:,i]))<jupyter_output><empty_output><jupyter_text>Label generation part and getting one hot encoded values<jupyter_code>labels = np.array(([0] * 8 + [1] * 8) * 20 + ([1] * 8 + [0] * 8) * 20)
def one_hot(labels):
    n_values = np.max(labels)
    return np.eye(n_values)[labels-1]
one_hot_labels = one_hot(labels+1) # The +1 part is a hack to get around array indexing problem
one_hot_labels[200:210] #sanity check from some random slice
np.sum(labels == np.argmax(one_hot_labels, axis=1)) #sanity check
np.save('04799-label-onehot.npy', one_hot_labels)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13051643192488263, 'fraction_numerical': 0.0431924882629108, 'mean_word_length': 5.70440251572327, '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': '612814', 'license': 'MIT', 'n_tokens_mistral': 427, 'n_tokens_neox': 394, 'n_words': 102, 'path': 'Visualizer.ipynb', 'repo_name': 'ArkAung/brain_cnn', 'size': '1065'}