<jupyter_start><jupyter_text><jupyter_code>#Importing Dataset
from keras.datasets import mnist
data = mnist.load_data()
data
type(data)<jupyter_output><empty_output><jupyter_text>Define Training and Testing Data<jupyter_code>(X_train, y_train),(X_test, y_test) = data
#Shape of Training Data
X_train[0].shape
#Reshape the Training Data
X_train = X_train.reshape((X_train.shape[0],28*28)).astype('float32')
X_test = X_test.reshape((X_test.shape[0],28*28)).astype('float32')
#Normalizing value from 0-255 to 0-1
X_train = X_train/255
X_test = X_test/255
from keras.utils import np_utils

y_train = np_utils.to_categorical(y_train)
y_test = np_utils.to_categorical(y_test)
num_classes = y_test.shape[1]
#import Library
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
#Define Model
model = Sequential()

#Add First and Second Hidden Layer
model.add(Dense(32, input_dim= 28*28, activation='relu'))
model.add(Dense(64,activation='relu'))

#Add output layer having 10 neurons(since there are 10 classes/categories)
model.add(Dense(10,activation='softmax'))
#Compile Model
model.compile(loss='categorical_crossentropy', optimizer = 'adam', metrics = ['accuracy'])
#Print Model Summary
model.summary()
#Train Model
model.fit(X_train,y_train, epochs=10, batch_size=100)<jupyter_output>Epoch 1/10
600/600 [==============================] - 2s 2ms/step - loss: 0.7881 - accuracy: 0.7754
Epoch 2/10
600/600 [==============================] - 1s 2ms/step - loss: 0.2043 - accuracy: 0.9410
Epoch 3/10
600/600 [==============================] - 1s 2ms/step - loss: 0.1566 - accuracy: 0.9540
Epoch 4/10
600/600 [==============================] - 1s 2ms/step - loss: 0.1339 - accuracy: 0.9600
Epoch 5/10
600/600 [==============================] - 1s 2ms/step - loss: 0.1117 - accuracy: 0.9673
Epoch 6/10
600/600 [==============================] - 1s 2ms/step - loss: 0.0964 - accuracy: 0.9708
Epoch 7/10
600/600 [==============================] - 1s 2ms/step - loss: 0.0916 - accuracy: 0.9716
Epoch 8/10
600/600 [==============================] - 1s 2ms/step - loss: 0.0753 - accuracy: 0.9770
Epoch 9/10
600/600 [==============================] - 1s 2ms/step - loss: 0.0723 - accuracy: 0.9777
Epoch 10/10
600/600 [==============================] - 1s 2ms/step - loss: 0.0673 - accuracy: 0.9801[...]<jupyter_text>Check Model Accuracy<jupyter_code>score = model.evaluate(X_test, y_test)
print(score)<jupyter_output>313/313 [==============================] - 0s 964us/step - loss: 0.1029 - accuracy: 0.9690
[0.10292311757802963, 0.968999981880188]
{'fraction_non_alphanumeric': 0.2505818463925524, 'fraction_numerical': 0.12102404965089217, 'mean_word_length': 5.646907216494846, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '337293', 'license': 'MIT', 'n_tokens_mistral': 1156, 'n_tokens_neox': 916, 'n_words': 208, 'path': 'Project_DL.ipynb', 'repo_name': 'abhijeetraj22/ShapeAI_DL', 'size': '2578'}