<jupyter_start><jupyter_text>CNN Structure as described  in paperm![image.png](attachment:image.png)<jupyter_code>from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten, Conv2D, AveragePooling2D, MaxPooling2D
from tensorflow.keras import Model
from modules.CNN_withSpectralPooling import build_model
SpectralPooling_3x3_ConvolutionModel = build_model(X_train.shape[1:],M=8,num_output=10,gamma=0.85)
SpectralPooling_3x3_ConvolutionModel.summary()
# Define Callbacks 

tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir="./logs")

earlystopping = tf.keras.callbacks.EarlyStopping(monitor='loss', patience=3)

SpectralPooling_3x3_ConvolutionModel.compile(
                        optimizer= tf.keras.optimizers.Adam(),
                        loss='sparse_categorical_crossentropy',
                        metrics=['accuracy']
)

history = SpectralPooling_3x3_ConvolutionModel.fit(x=X_train, y=y_train,
                                          batch_size=128,
                                          epochs=25, 
                                          validation_data=(X_val, y_val),
                                          callbacks=[earlystopping,tensorboard_callback]
                                              )
# Save the model
SpectralPooling_3x3_ConvolutionModel.save('3x3Spectral_Pooling_Convolution.h5') # Save model

# Save the history so as to make the plot
import pickle
with open('history_3x3Spectral_Pooling_Convolution', 'wb') as file_pi:
        pickle.dump(history.history, file_pi)
results = SpectralPooling_3x3_ConvolutionModel.evaluate(X_test, y_test, batch_size=128)
print("test loss, test acc:", results)
SpectralPooling_3x3_ConvolutionModel.save('tensorflow/SpectralPooling_3x3_ConvolutionModel')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08282716731087797, 'fraction_numerical': 0.022087244616234125, 'mean_word_length': 3.2535211267605635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '243111', 'license': 'MIT', 'n_tokens_mistral': 566, 'n_tokens_neox': 533, 'n_words': 82, 'path': 'src/final-JupyterNotebooks/spectral_pooling/3x3-SpectralPoolingCNN-Convolution-CIFAR10.ipynb', 'repo_name': 'aye21874/Spectral-Representations-for-Convolutional-Neural-Networks', 'size': '1811'}