<jupyter_start><jupyter_text>Load data<jupyter_code>from keras.datasets import mnist
(train_images, train_labels), (test_images, test_labels)=mnist.load_data()<jupyter_output><empty_output><jupyter_text>Explore data<jupyter_code>print(train_images.shape)
print(train_labels.shape)
print(test_images.shape)
print(test_labels.shape)
from keras import models
from keras import layers
nn=models.Sequential()
nn.add(layers.Dense(512, activation='relu', input_shape=(28*28,)))
nn.add(layers.Dense(10, activation='softmax'))<jupyter_output><empty_output><jupyter_text>See architecture and number of trainable parameters<jupyter_code>nn.summary()
nn.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])<jupyter_output><empty_output><jupyter_text>Preparing image data<jupyter_code>train_images=train_images.reshape((60000,28*28))
train_images=train_images.astype('float32')/255

test_images=test_images.reshape((10000,28*28))
test_images=test_images.astype('float32')/255<jupyter_output><empty_output><jupyter_text>Preparing labels<jupyter_code>from keras.utils import to_categorical

train_labels=to_categorical(train_labels)
test_labels=to_categorical(test_labels)<jupyter_output><empty_output><jupyter_text>Train model<jupyter_code>nn.fit(train_images, train_labels, epochs=5, batch_size=128)<jupyter_output>Epoch 1/5
60000/60000 [==============================] - 5s 87us/step - loss: 0.2598 - acc: 0.9248
Epoch 2/5
60000/60000 [==============================] - 5s 84us/step - loss: 0.1050 - acc: 0.9690
Epoch 3/5
60000/60000 [==============================] - 5s 85us/step - loss: 0.0706 - acc: 0.9785
Epoch 4/5
60000/60000 [==============================] - 5s 83us/step - loss: 0.0510 - acc: 0.9849
Epoch 5/5
60000/60000 [==============================] - 5s 86us/step - loss: 0.0381 - acc: 0.9888<jupyter_text>Evaluate Test<jupyter_code>test_loss, test_acc=nn.evaluate(test_images, test_labels)
print('test_acc:', test_acc)<jupyter_output>10000/10000 [==============================] - 1s 52us/step
test_acc: 0.9814
{'fraction_non_alphanumeric': 0.21065493646138808, 'fraction_numerical': 0.08993157380254155, 'mean_word_length': 9.551546391752577, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '28257', 'license': 'MIT', 'n_tokens_mistral': 886, 'n_tokens_neox': 745, 'n_words': 104, 'path': '1_denselayer_mnist.ipynb', 'repo_name': 'apdullahyayik/tensorflowWorks', 'size': '2046'}