<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_spectral_conv_model_5x5
SpectralPooling_5x5_SpectralConvolutionModel = build_spectral_conv_model_5x5(X_train.shape[1:],M=8,num_output=10,gamma=0.85)
SpectralPooling_5x5_SpectralConvolutionModel.summary()
batch_size=128
nb_epochs=50

output_size=10

train_generator = datagen.flow(X_train, y_train, batch_size=batch_size)
valid_generator = datagen.flow(X_val, y_val, batch_size=batch_size)

SpectralPooling_5x5_SpectralConvolutionModel.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])

history=SpectralPooling_5x5_SpectralConvolutionModel.fit_generator(train_generator,epochs=nb_epochs,steps_per_epoch=len(X_train)//batch_size, validation_data=valid_generator)


# Save the model
SpectralPooling_5x5_SpectralConvolutionModel.save('5x5Spectral_Pooling_SpectralConvolution.h5') # Save model

# Save the history so as to make the plot
import pickle
with open('history_5x5Spectral_Pooling_SpectralConvolution', 'wb') as file_pi:
        pickle.dump(history.history, file_pi)
results = SpectralPooling_5x5_SpectralConvolutionModel.evaluate(X_test, y_test, batch_size=128)
print("test loss, test acc:", results)
SpectralPooling_5x5_SpectralConvolutionModel.save('tensorflow/SpectralPooling_5x5_SpectralConvolutionModel')<jupyter_output>INFO:tensorflow:Assets written to: tensorflow/spectral_pooling_cifar10/assets
{'fraction_non_alphanumeric': 0.08145065398335315, 'fraction_numerical': 0.02794292508917955, 'mean_word_length': 11.946153846153846, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '54525', 'license': 'MIT', 'n_tokens_mistral': 619, 'n_tokens_neox': 584, 'n_words': 81, 'path': 'src/final-JupyterNotebooks/spectral_pooling/5x5-SpectralPoolingCNN-SpectralConvolution-CIFAR10.ipynb', 'repo_name': 'aye21874/Spectral-Representations-for-Convolutional-Neural-Networks', 'size': '1682'}