<jupyter_start><jupyter_text>For vanilla cnn<jupyter_code>import numpy as np
import tensorflow as tf
import h5py
A01T = h5py.File("./project_datasets/A01T_slice.mat", 'r')
X = np.copy(A01T["image"])
y = np.copy(A01T["type"])
y = y[0, 0:X.shape[0]:1]
y = np.asarray(y, dtype=np.int32)
print("shape of X:", X.shape)
print("shape of y:", y.shape)
print(y)<jupyter_output>[772 771 770 769 769 770 771 772 770 771 769 769 769 772 770 770 769 769
 771 769 770 772 772 771 769 772 772 770 772 772 770 769 770 771 771 771
 772 771 769 772 770 771 770 771 772 770 771 769 769 769 772 770 769 771
 769 771 770 772 769 771 771 769 771 770 772 772 772 771 769 772 770 772
 770 769 771 770 769 771 771 769 771 772 772 770 769 770 772 770 772 771
 770 770 770 771 772 769 770 772 769 771 771 772 769 769 771 770 772 772
 772 770 769 771 770 772 769 772 771 770 772 772 769 770 770 771 772 770
 769 769 772 770 769 771 770 770 771 769 772 771 771 771 771 769 770 769
 770 769 769 771 771 770 771 772 769 772 769 769 770 772 771 770 772 771
 772 771 772 770 770 772 769 770 770 770 771 772 769 772 769 771 769 772
 769 771 769 770 771 771 772 769 770 772 770 771 771 769 772 770 772 769
 769 771 771 770 772 770 770 769 770 772 772 770 770 770 770 772 772 771
 772 769 770 771 770 769 772 769 772 769 769 769 769 771 771 772 770 771
 771 771 772 771 769 771 769 772 770 772 772 771 77[...]<jupyter_text>Build a 1 layer cnn with tf<jupyter_code>x_in = tf.placeholder(tf.float32, [None, 25, 1000], name="input_x")
y_real = tf.placeholder(tf.int32, [None], name="real_y")
input_layer = tf.reshape(x_in, [-1, 25, 1000, 1], name="reshaped_x")

conv1 = tf.layers.conv2d(
    inputs=input_layer,
    filters=32,
    kernel_size=[3, 3],
    padding="same",
    activation=tf.nn.relu)
pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2, 2], strides=2)

conv2 = tf.layers.conv2d(
    inputs=pool1,
    filters=64,
    kernel_size=[3, 3],
    padding="same",
    activation=tf.nn.relu)
pool2 = tf.layers.max_pooling2d(inputs=conv2, pool_size=[2, 2], strides=2)

pool2_flat = tf.reshape(pool2, [-1, (25*1000*64)//16])
aff3 = tf.layers.dense(inputs=pool2_flat, units=1024, activation=tf.nn.relu)

logits = tf.layers.dense(inputs=aff3, units=4)

loss = tf.losses.sparse_softmax_cross_entropy(labels=y_real, logits=logits)
optimizer = tf.train.AdamOptimizer().minimize(loss)
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    for i in range(1):
        inputs = {x_in: X, y_real: y}
        loss, _ = sess.run([loss, optimizer], feed_dict=inputs)
        print("loss is:", loss)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10639112131649445, 'fraction_numerical': 0.3145809414466131, 'mean_word_length': 3.9601518026565463, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '204356', 'license': 'MIT', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1165, 'n_words': 365, 'path': 'vanilla_cnn_ipython.ipynb', 'repo_name': 'charliezjw/Neural-Signal-Decoder', 'size': '2613'}