<jupyter_start><jupyter_text>Importing the data<jupyter_code>import pandas as pd
import numpy as np
from tensorflow.keras.datasets.mnist import load_data
(x_train, y_train), (x_test, y_test) = load_data()<jupyter_output><empty_output><jupyter_text>recaling the images<jupyter_code>x_train = np.array(x_train/255.0)
x_test = np.array(x_test/255.0)
x_train.shape
from skimage.transform import resize<jupyter_output><empty_output><jupyter_text>resizing the images to match the LENET-5's input requirement<jupyter_code>x_train = np.array(resize(x_train,(60000, 32, 32, 1)))
x_test = np.array(resize(x_test,(10000, 32, 32, 1)))
y_train = pd.get_dummies(y_train)
y_test = pd.get_dummies(y_test)
import tensorflow as tf
from tensorflow.keras.layers import Conv2D,Flatten,AveragePooling2D,Dense
from tensorflow.keras.models import Sequential
#LENET-5 architecture
model = Sequential()
model.add(Conv2D(6,kernel_size=(5,5),strides=(1,1),activation='tanh',input_shape=(32,32,1)))
model.add(AveragePooling2D(2,strides=2))
model.add(Conv2D(16,kernel_size=(5,5),strides=(1,1),activation='tanh'))
model.add(AveragePooling2D(2,strides=2))
model.add(Conv2D(120,kernel_size=(5,5),strides=(1,1),activation='tanh'))
model.add(Flatten())
model.add(Dense(84,activation='tanh'))
model.add(Dense(10,activation='softmax'))
model.summary()
model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'])
history = model.fit(x_train,y_train,batch_size=32,epochs=15,validation_split=0.2,shuffle=True,verbose=2)
loss, acc = model.evaluate(x_test, y_test, verbose=2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15239294710327456, 'fraction_numerical': 0.04785894206549118, 'mean_word_length': 11.511811023622048, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '593679', 'license': 'MIT', 'n_tokens_mistral': 664, 'n_tokens_neox': 618, 'n_words': 83, 'path': 'mnist_cnn_lenet.ipynb', 'repo_name': 'bharathreddy3468/CNN', 'size': '1588'}