<jupyter_start><jupyter_text>Creating the neural network<jupyter_code>model = keras.Sequential()
model.add(Flatten(input_shape=[28,28]))
model.add(layers.Dense(20, activation="relu")) #hidden layer1
model.add(layers.Dense(20, activation="relu")) #hidden layer2
model.add(layers.Dense(20, activation="relu")) #hidden layer3
model.add(layers.Dense(20, activation="relu")) #hidden layer1
model.add(layers.Dense(20, activation="relu")) #hidden layer2
model.add(layers.Dense(20, activation="relu")) #hidden layer3
model.add(layers.Dense(10, activation="softmax")) #output layer
model.summary()
model.compile(loss="sparse_categorical_crossentropy",
              optimizer="adam",
              metrics=["accuracy"])<jupyter_output><empty_output><jupyter_text>Train the network<jupyter_code>model.fit(x_train, y_train, epochs=10)<jupyter_output>Epoch 1/10
1875/1875 [==============================] - 4s 2ms/step - loss: 1.3001 - accuracy: 0.4743
Epoch 2/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.9428 - accuracy: 0.6464
Epoch 3/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.7637 - accuracy: 0.7157
Epoch 4/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.6701 - accuracy: 0.7507
Epoch 5/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.6157 - accuracy: 0.7699
Epoch 6/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.5717 - accuracy: 0.7868
Epoch 7/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.5419 - accuracy: 0.7991
Epoch 8/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.5194 - accuracy: 0.8081
Epoch 9/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.4998 - accuracy: 0.8168
Epoch 10/10
1875/1875 [==============================] - 4s 2ms/step - loss: 0.482[...]<jupyter_text>Test the network<jupyter_code>plt.matshow(x_test[5])
x_test.shape<jupyter_output><empty_output><jupyter_text>Make a prediction through our model and test the highest probability value from array 0-9<jupyter_code>yp = model.predict(x_test)
yp[5]<jupyter_output><empty_output><jupyter_text>Check to see which argument corresponds to the probability listened<jupyter_code>np.argmax(yp[5])<jupyter_output><empty_output><jupyter_text>Let's measure the accuracy(loss, accuracyscore)<jupyter_code>model.evaluate(x_test, y_test)<jupyter_output>313/313 [==============================] - 0s 1ms/step - loss: 0.4524 - accuracy: 0.8464
{'fraction_non_alphanumeric': 0.2618855761482675, 'fraction_numerical': 0.11039484286865431, 'mean_word_length': 6.0141242937853105, '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': '613751', 'license': 'MIT', 'n_tokens_mistral': 1058, 'n_tokens_neox': 866, 'n_words': 168, 'path': 'image classification/Image Classification with Keras.ipynb', 'repo_name': 'Stosan/Deep-Learning-with-Keras', 'size': '2482'}