<jupyter_start><jupyter_text>Here we have my attempt at the python examples found in Chollet's Deep Learning book, using Keras: hosted on Colab because I don't have access to a GPU otherwise!<jupyter_code>import keras
keras.__version__<jupyter_output><empty_output><jupyter_text>First, most basic example - two-layer network for classifying the MNIST digits<jupyter_code>(train_images, train_labels), (test_images, test_labels) = keras.datasets.mnist.load_data()
# Load and preprocess input data

train_images = train_images.reshape((60000, 28*28))  # Why can't I work with the 2D matrices directly?
train_images = train_images.astype("float32") /255

test_images = test_images.reshape((10000, 28*28))
test_images = test_images.astype("float32") /255

train_labels = keras.utils.to_categorical(train_labels)
test_labels = keras.utils.to_categorical(test_labels)
# Create two-layer model

network = keras.models.Sequential()
network.add(keras.layers.Dense(512, activation="relu", input_shape=(28*28,)))
# MNIST has ten classes so softmax with 10 nodes gives us classification probabilities
network.add(keras.layers.Dense(10, activation="softmax"))  
network.compile(optimizer="rmsprop", loss="categorical_crossentropy", metrics=["accuracy"])
network.fit(train_images, train_labels, epochs=5, batch_size=128)
test_loss, test_acc = network.evaluate(test_images, test_labels)
print(f"test accuracy: {test_acc:.3f}")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11034004163775156, 'fraction_numerical': 0.031228313671061762, 'mean_word_length': 7.901234567901234, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '177251', 'license': 'MIT', 'n_tokens_mistral': 507, 'n_tokens_neox': 467, 'n_words': 112, 'path': 'Chapter1.ipynb', 'repo_name': 'wllgrnt/keras-examples', 'size': '1441'}