<jupyter_start><jupyter_text>Deep Convolutional Neural Network in TensorFlow In this notebook, we build a deep, convolutional, MNIST-classifying network inspired by [LeNet-5](http://yann.lecun.com/exdb/publis/pdf/lecun-01a.pdf). [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/jonkrohn/DLTFpT/blob/master/notebooks/lenet_in_tensorflow.ipynb)  Load dependencies<jupyter_code>import tensorflow
from tensorflow.keras.datasets import mnist
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.layers import Flatten, Conv2D, MaxPooling2D # new!<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>(X_train, y_train), (X_valid, y_valid) = mnist.load_data()<jupyter_output><empty_output><jupyter_text>Preprocess data<jupyter_code>X_train = X_train.reshape(60000, 28, 28, 1).astype('float32')
X_valid = X_valid.reshape(10000, 28, 28, 1).astype('float32')
X_train /= 255
X_valid /= 255
n_classes = 10
y_train = to_categorical(y_train, n_classes)
y_valid = to_categorical(y_valid, n_classes)<jupyter_output><empty_output><jupyter_text>Design neural network architecture<jupyter_code>model = Sequential()

model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=(28, 28, 1)))

model.add(Conv2D(64, kernel_size=(3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())

model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))

model.add(Dense(n_classes, activation='softmax'))
model.summary()<jupyter_output><empty_output><jupyter_text>Configure model<jupyter_code>model.compile(loss='categorical_crossentropy', optimizer='nadam', metrics=['accuracy'])<jupyter_output><empty_output><jupyter_text>Train!<jupyter_code>model.fit(X_train, y_train, batch_size=128, epochs=10, verbose=1, validation_data=(X_valid, y_valid))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14016840019811788, 'fraction_numerical': 0.03417533432392273, 'mean_word_length': 9.631578947368421, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '272102', 'license': 'MIT', 'n_tokens_mistral': 817, 'n_tokens_neox': 759, 'n_words': 110, 'path': 'notebooks/lenet_in_tensorflow.ipynb', 'repo_name': 'ewbolme/DLTFpT', 'size': '2019'}