<jupyter_start><jupyter_text>Shallow Neural Network in Keras  Load dependencies<jupyter_code>import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import SGD<jupyter_output>Using TensorFlow backend.<jupyter_text>Load data<jupyter_code>(X_train, y_train), (X_test, y_test) = mnist.load_data()
X_train.shape
y_train.shape
y_train[0:100]
X_train[0]<jupyter_output><empty_output><jupyter_text>Preprocess Data<jupyter_code>X_train = X_train.reshape(60000, 784).astype('float32')
X_test = X_test.reshape(10000, 784).astype('float32')
X_train /= 255
X_test /= 255
n_classes = 10
y_train = keras.utils.to_categorical(y_train, n_classes)
y_test = keras.utils.to_categorical(y_test, n_classes)
X_train[0]
y_train[0]<jupyter_output><empty_output><jupyter_text>Design neural network architecture<jupyter_code>model = Sequential()
model.add(Dense(64, activation='sigmoid', input_shape=(784,)))
model.add(Dense(10, activation='softmax'))
model.summary()
(64*784)+64
(10*64)+10<jupyter_output><empty_output><jupyter_text>Configure model<jupyter_code>model.compile(loss='mean_squared_error', optimizer=SGD(lr=0.01), metrics=['accuracy'])<jupyter_output><empty_output><jupyter_text>Train<jupyter_code>model.fit(X_train, y_train, validation_data=(X_test, y_test), batch_size=128, epochs=10, verbose=1)<jupyter_output>Train on 60000 samples, validate on 10000 samples
Epoch 1/10
60000/60000 [==============================] - 1s - loss: 0.0916 - acc: 0.1020 - val_loss: 0.0911 - val_acc: 0.1192
Epoch 2/10
60000/60000 [==============================] - 1s - loss: 0.0907 - acc: 0.1389 - val_loss: 0.0904 - val_acc: 0.1621
Epoch 3/10
60000/60000 [==============================] - 1s - loss: 0.0901 - acc: 0.1754 - val_loss: 0.0898 - val_acc: 0.1956
Epoch 4/10
60000/60000 [==============================] - 1s - loss: 0.0896 - acc: 0.1995 - val_loss: 0.0894 - val_acc: 0.2190
Epoch 5/10
60000/60000 [==============================] - 1s - loss: 0.0892 - acc: 0.2267 - val_loss: 0.0890 - val_acc: 0.2546
Epoch 6/10
60000/60000 [==============================] - 1s - loss: 0.0888 - acc: 0.2712 - val_loss: 0.0886 - val_acc: 0.2963
Epoch 7/10
60000/60000 [==============================] - 1s - loss: 0.0885 - acc: 0.3150 - val_loss: 0.0882 - val_acc: 0.3321
Epoch 8/10
60000/60000 [==============================] - 1s [...]
{'fraction_non_alphanumeric': 0.23060796645702306, 'fraction_numerical': 0.13668763102725368, 'mean_word_length': 6.165165165165165, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '228187', 'license': 'MIT', 'n_tokens_mistral': 1148, 'n_tokens_neox': 920, 'n_words': 171, 'path': 'notebooks/shallow_net_in_keras.ipynb', 'repo_name': 'nirupam1sharma/my-course', 'size': '2385'}