<jupyter_start><jupyter_text>Deep Convolutional Neural Net in TensorFlow 2.0 LeNet-5 inspired model for classifying MNIST digits_Remember to change your Runtime to GPU or TPU._  Load dependencies<jupyter_code>pip install tensorflow==2.0.0-beta0
import tensorflow as tf
from tensorflow import keras<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>(X_train, y_train), (X_valid, y_valid) = keras.datasets.mnist.load_data()<jupyter_output>Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
11493376/11490434 [==============================] - 0s 0us/step<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 = keras.utils.to_categorical(y_train, n_classes)
y_valid = keras.utils.to_categorical(y_valid, n_classes)<jupyter_output><empty_output><jupyter_text>Design neural network architecture<jupyter_code>model = keras.models.Sequential([
    
    keras.layers.Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=(28, 28, 1)),
    
    keras.layers.Conv2D(64, kernel_size=(3, 3), activation='relu'),
    keras.layers.MaxPooling2D(pool_size=(2, 2)),
    keras.layers.Flatten(),
    
    keras.layers.Dense(128, activation='relu'),
    # keras.layers.BatchNormalization(),
    keras.layers.Dropout(0.2),
    
    keras.layers.Dense(10, activation='softmax'),
])
model.summary()<jupyter_output>Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d (Conv2D)              (None, 26, 26, 32)        320       
_________________________________________________________________
conv2d_1 (Conv2D)            (None, 24, 24, 64)        18496     
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 12, 12, 64)        0         
_________________________________________________________________
flatten (Flatten)            (None, 9216)              0         
_________________________________________________________________
dense (Dense)                (None, 128)               1179776   
_________________________________________________________________
dropout (Dropout)            (None, 128)               0         
________________________________________________________[...]<jupyter_text>Configure model<jupyter_code>model.compile(loss='categorical_crossentropy', optimizer='adam', 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.13539109084531742, 'fraction_numerical': 0.049456331111890565, 'mean_word_length': 5.0423728813559325, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '240466', 'license': 'MIT', 'n_tokens_mistral': 953, 'n_tokens_neox': 840, 'n_words': 144, 'path': 'notebooks/lenet.ipynb', 'repo_name': 'jonkrohn/tf2', 'size': '2851'}