Unverified Commit 5a6075a9 authored by Kiryuu Sakuya's avatar Kiryuu Sakuya 🎵
Browse files

Finish 06

parent 9f8762fb
%% Cell type:code id: tags:
``` python
# -*- coding: utf-8 -*-
import tensorflow as tf
import tensorflow_datasets as tfds
import numpy as np
import matplotlib.pyplot as plt
datasets = tfds.load("cifar10")
train_dataset, test_dataset = datasets["train"], datasets["test"]
assert isinstance(train_dataset, tf.data.Dataset)
cifar10_builder = tfds.builder("cifar10")
# See the information on the dataset
# info = cifar10_builder.info
# print(info)
for batch in train_dataset.batch(50000):
x_train = batch['image']
y_train = batch['label'].numpy().astype('uint8')
for batch in test_dataset.batch(10000):
x_test = batch['image']
y_test = batch['label'].numpy().astype('uint8')
# Normalize pixel values to be between 0 and 1
x_test = x_test / 255
x_train = x_train / 255
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(32, 32, 3)),
tf.keras.layers.Conv2D(32, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(64, (3, 3), padding='same', activation='relu'),
tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(128, (3, 3), padding='same', activation='relu'),
tf.keras.layers.Conv2D(128, (3, 3), activation='relu'),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.summary()
history = model.fit(x_train, y_train, epochs=25, validation_data=(x_test, y_test))
plt.plot(history.history['accuracy'], label='accuracy')
plt.plot(history.history['val_accuracy'], label = 'val_accuracy')
plt.xlabel('Epoch')
plt.ylabel('Accuracy')
plt.ylim([0.5, 1])
plt.legend(loc='lower right')
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)
print(test_acc)
```
%%%% Output: stream
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 32, 32, 32) 896
_________________________________________________________________
conv2d_1 (Conv2D) (None, 30, 30, 32) 9248
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 15, 15, 32) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 15, 15, 64) 18496
_________________________________________________________________
conv2d_3 (Conv2D) (None, 13, 13, 64) 36928
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 6, 6, 64) 0
_________________________________________________________________
conv2d_4 (Conv2D) (None, 6, 6, 128) 73856
_________________________________________________________________
conv2d_5 (Conv2D) (None, 4, 4, 128) 147584
_________________________________________________________________
flatten (Flatten) (None, 2048) 0
_________________________________________________________________
dense (Dense) (None, 512) 1049088
_________________________________________________________________
dense_1 (Dense) (None, 10) 5130
=================================================================
Total params: 1,341,226
Trainable params: 1,341,226
Non-trainable params: 0
_________________________________________________________________
Train on 50000 samples, validate on 10000 samples
Epoch 1/25
50000/50000 [==============================] - 11s 222us/sample - loss: 1.8240 - accuracy: 0.3118 - val_loss: 1.3156 - val_accuracy: 0.5234
Epoch 2/25
50000/50000 [==============================] - 9s 188us/sample - loss: 1.2001 - accuracy: 0.5697 - val_loss: 1.0962 - val_accuracy: 0.6127
Epoch 3/25
50000/50000 [==============================] - 9s 189us/sample - loss: 0.9846 - accuracy: 0.6485 - val_loss: 0.9977 - val_accuracy: 0.6536
Epoch 4/25
50000/50000 [==============================] - 9s 190us/sample - loss: 0.8443 - accuracy: 0.6998 - val_loss: 0.9282 - val_accuracy: 0.6743
Epoch 5/25
50000/50000 [==============================] - 10s 191us/sample - loss: 0.7312 - accuracy: 0.7406 - val_loss: 0.8810 - val_accuracy: 0.6998
Epoch 6/25
50000/50000 [==============================] - 10s 193us/sample - loss: 0.6365 - accuracy: 0.7745 - val_loss: 0.9132 - val_accuracy: 0.7010
Epoch 7/25
50000/50000 [==============================] - 10s 195us/sample - loss: 0.5455 - accuracy: 0.8071 - val_loss: 0.8799 - val_accuracy: 0.7140
Epoch 8/25
50000/50000 [==============================] - 10s 198us/sample - loss: 0.4616 - accuracy: 0.8364 - val_loss: 0.9225 - val_accuracy: 0.7222
Epoch 9/25
50000/50000 [==============================] - 10s 198us/sample - loss: 0.3835 - accuracy: 0.8635 - val_loss: 0.9979 - val_accuracy: 0.7218
Epoch 10/25
50000/50000 [==============================] - 10s 198us/sample - loss: 0.3254 - accuracy: 0.8840 - val_loss: 1.0933 - val_accuracy: 0.7060
Epoch 11/25
50000/50000 [==============================] - 10s 199us/sample - loss: 0.2725 - accuracy: 0.9036 - val_loss: 1.2116 - val_accuracy: 0.7198
Epoch 12/25
50000/50000 [==============================] - 10s 199us/sample - loss: 0.2417 - accuracy: 0.9146 - val_loss: 1.2796 - val_accuracy: 0.7161
Epoch 13/25
50000/50000 [==============================] - 10s 200us/sample - loss: 0.2063 - accuracy: 0.9288 - val_loss: 1.4144 - val_accuracy: 0.7084
Epoch 14/25
50000/50000 [==============================] - 10s 201us/sample - loss: 0.2050 - accuracy: 0.9299 - val_loss: 1.4991 - val_accuracy: 0.7148
Epoch 15/25
50000/50000 [==============================] - 10s 200us/sample - loss: 0.1794 - accuracy: 0.9389 - val_loss: 1.5313 - val_accuracy: 0.7107
Epoch 16/25
50000/50000 [==============================] - 10s 202us/sample - loss: 0.1695 - accuracy: 0.9430 - val_loss: 1.6222 - val_accuracy: 0.7091
Epoch 17/25
50000/50000 [==============================] - 10s 201us/sample - loss: 0.1691 - accuracy: 0.9450 - val_loss: 1.6515 - val_accuracy: 0.7084
Epoch 18/25
50000/50000 [==============================] - 10s 199us/sample - loss: 0.1563 - accuracy: 0.9482 - val_loss: 1.7664 - val_accuracy: 0.7125
Epoch 19/25
50000/50000 [==============================] - 10s 199us/sample - loss: 0.1578 - accuracy: 0.9478 - val_loss: 1.6861 - val_accuracy: 0.7075
Epoch 20/25
50000/50000 [==============================] - 10s 200us/sample - loss: 0.1529 - accuracy: 0.9503 - val_loss: 1.7353 - val_accuracy: 0.7086
Epoch 21/25
50000/50000 [==============================] - 10s 200us/sample - loss: 0.1385 - accuracy: 0.9560 - val_loss: 1.8987 - val_accuracy: 0.7115
Epoch 22/25
50000/50000 [==============================] - 10s 201us/sample - loss: 0.1380 - accuracy: 0.9552 - val_loss: 1.9733 - val_accuracy: 0.7052
Epoch 23/25
50000/50000 [==============================] - 10s 205us/sample - loss: 0.1446 - accuracy: 0.9538 - val_loss: 1.9660 - val_accuracy: 0.7088
Epoch 24/25
50000/50000 [==============================] - 10s 203us/sample - loss: 0.1413 - accuracy: 0.9556 - val_loss: 2.0789 - val_accuracy: 0.7071
Epoch 25/25
50000/50000 [==============================] - 10s 202us/sample - loss: 0.1368 - accuracy: 0.9576 - val_loss: 1.9133 - val_accuracy: 0.7102
0.7102
%%%% Output: display_data
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYYAAAEKCAYAAAAW8vJGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3dd3xUZdr/8c+d3kOAUELoNVTpIhaKID5iAwuIDbs/cV10V3dZXXWL66pb3EeFBwWVtWBBBJGFFUWwoBKQHppAJJCEkJBepl2/P84kJCGBSchkQuZ6v17zmjlnzsxcJwPnO+c+97mPERGUUkqpcgG+LkAppVTTosGglFKqCg0GpZRSVWgwKKWUqkKDQSmlVBUaDEopparwWjAYYxYaY44ZY3bU8rwxxvzLGLPfGLPNGDPEW7UopZTynDf3GN4AJp3m+cuBnu7bPcBcL9ailFLKQ14LBhFZD+ScZpGrgUVi+Q5oYYxp7616lFJKeSbIh5/dAThcaTrNPS+9+oLGmHuw9iqIjIwc2qdPn0YpUCmlmotNmzYdF5F4T5b1ZTCYGubVOD6HiMwH5gMMGzZMkpOTvVmXUko1O8aYVE+X9WWvpDSgY6XpROCoj2pRS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AX4pIvm+rqex1bD+df7+/SUYzjg8R3MmIkfd98eApVhNa/4m090GW94We8zH9TQaEckUEaeIuIBXacbfvzEmGGuj+LaIfOSe7TfffU3rX5/v31+C4YzDczRXxphI94EojDGRwERgx+lf1SwtB25zP74NWObDWhpV+UbR7Vqa6ffvHl5nAZAiIn+v9JRffPe1rX99vn+/6JUE4O6i9U9ODs/xZx+X1CiMMd2w9hLAGgLlnea+7saYd4ExWEMOZwJPYo3c+z7QCfgZuF5Emt1B2lrWfQxWM4IAh4B7y9vcmxNjzIXAV8B2wOWePQernd0fvvva1n86dfz+/SYYlFJKecZfmpKUUkp5SINBKaVUFRoMSimlqtBgUEopVYUGg1JKqSo0GJSqxhjjrDQS5ZaGHI3XGNOl8sinSjVFXru0p1LnsBIROc/XRSjlK7rHoJSH3Ne1+Ksx5gf3rYd7fmdjzOfuQco+N8Z0cs9va4xZaozZ6r5d4H6rQGPMq+4x8/9rjAn32UopVQMNBqVOFV6tKenGSs/li8gI4CWsM+lxP14kIgOBt4F/uef/C1gnIoOAIcBO9/yewMsi0g/IBaZ6eX2UqhM981mpaowxhSISVcP8Q8A4ETngHqwsQ0RaGWOOY10gxe6eny4irY0xWUCiiJRVeo8uwGci0tM9/RgQLCJ/8v6aKeUZ3WNQqm6klse1LVOTskqPneixPtXEaDAoVTc3Vrrf4H78LdaIvQAzgK/djz8H7gfr8rLGmJjGKlKps6G/VJQ6VbgxZkul6VUiUt5lNdQY8z3Wj6rp7nm/ABYaY34NZAEz3fMfAuYbY+7E2jO4H+tCKUo1aXqMQSkPuY8xDBOR476uRSlv0qYkpZRSVegeg1JKqSp0j0EppVQVGgxKKaWq0GBQSilVhQaDUkqpKjQYlFJKVfH/AW7NEm7bYhT4AAAAAElFTkSuQmCC)
%% Cell type:code id: tags:
``` python
```
# -*- coding: utf-8 -*-
import tensorflow as tf
import tensorflow_datasets as tfds
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
datasets = tfds.load("cifar10")
train_dataset, test_dataset = datasets["train"], datasets["test"]
assert isinstance(train_dataset, tf.data.Dataset)
cifar10_builder = tfds.builder("cifar10")
# See the information on the dataset
# info = cifar10_builder.info
# print(info)
for batch in train_dataset.batch(50000):
x_train = batch['image']
y_train = batch['label'].numpy().astype('uint8')
for batch in test_dataset.batch(10000):
x_test = batch['image']
y_test = batch['label'].numpy().astype('uint8')
# Normalize pixel values to be between 0 and 1
x_test = x_test / 255
x_train = x_train / 255
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(32, 32, 3)),
tf.keras.layers.Conv2D(32, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(64, (3, 3), padding='same', activation='relu'),
tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(128, (3, 3), padding='same', activation='relu'),
tf.keras.layers.Conv2D(128, (3, 3), activation='relu'),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.summary()
callbacks = [
# Write TensorBoard logs to `./logs` directory
tf.keras.callbacks.TensorBoard(log_dir='logs/{}'.format(dt.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")))
]
history = model.fit(x_train, y_train, epochs=50, validation_data=(x_test, y_test), callbacks=callbacks)
# plt.plot(history.history['accuracy'], label='accuracy')
# plt.plot(history.history['val_accuracy'], label = 'val_accuracy')
# plt.xlabel('Epoch')
# plt.ylabel('Accuracy')
# plt.ylim([0.5, 1])
# plt.legend(loc='lower right')
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)
print(test_acc)
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment