TensorFlow/tensorflow-mnist-gpu-tutorial.ipynb

478 lines
179 KiB
Text
Raw Normal View History

2021-12-14 00:35:39 +00:00
{
"cells": [
{
"attachments": {
"image.png": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABBwAAAHqCAYAAACnaF2mAAAgAElEQVR4AeydBXgc1frG0zZ1F6BQnOLe0tIWd3eKXvxiF+gfu3C52IW2VChQ3N2dQrGiRSuRJnX3uLvu+3/eM53d2c1akk2yu3nP80x3dubob7Y5M+985/sSoCQCIiACIiACIiACIiACIiACIiACIiACESSQwBTB+lSVCIiACIiACIiACIiACIiACIiACIiACECCg34EIiACIiACIiACIiACIiACIiACIiACEScgwSHiSFWhCIiACIiACIiACIiACIiACIiACIiABAf9BkRABERABERABERABERABERABERABCJOQIJDxJGqQhEQAREQAREQAREQAREQAREQAREQAQkO+g2IgAiIgAiIgAiIgAiIgAiIgAiIgAhEnIAEh4gjVYUiIAIiIAIiIAIiIAIiIAIiIAIiIAJBBYcDDjiAYSy0iYF+A/oN6Deg34B+A/oN6Deg34B+A/oN6Deg34B+A3H6Gxg8eHCLqCNBBQeKDUoiIAIiIAIiIAIiIAIiIAIiIAIiIALxS6Clnv0lOMTvb0YjEwEREAEREAEREAEREAEREAEREIGQBCQ4hESkDCIgAiIgAiIgAiIgAiIgAiIgAiIgAo0lIMGhscSUXwREQAREQAREQAREQAREQAREQAREICQBCQ4hESmDCIiACIiACIiACIiACIiACIiACIhAYwlIcGgsMeUXAREQAREQAREQAREQAREQAREQAREISUCCQ0hEyiACIiACIiACIiACIiACIiACIiACItBYAhIcGktM+UVABERABERABERABERABERABERABEISkOAQEpEyiIAIiIAIiIAIiIAIiIAIiIAIiIAINJaABIfGElN+ERABERABERABERABERABERABERCBkAQkOIREpAwiIAIiIAIiIAIiIAIiIAIiIAIiIAKNJSDBobHElF8EREAEREAEREAEREAEREAEREAERCAkAQkOIREpgwiIgAiIgAiIgAiIgAiIgAiIgAiIQGMJSHBoLDHlFwEREAEREAEREAEREA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WLz5sB56ZGZHrbpWTsvzzsfb4rS0iyri6oq6xz7ce+9ANcANjX99Rdw993WWM4/Hxg/Hli+PLzaSkosh468WSOLiy6y2DTGQefbbwMXXmiVv+suICXFarsxggPFovvvt+q44grLwzjX48ZSkg+HWLpa6qsItE8CsSQ48ApxrtxjD2tu79jR/1z56aeeuZ/+mzjGQGnuXGvOPfdc4IILgJdfDp6f9Xz7LcB57tdfA9Vq9ZN5OP/zPqC21jsvnVkuWABkZ1vHeS/w739b0TgKC73zhvstJ8eK4vWPf1hz53/+0zifVenpwIQJVtlLLrEiSv3xR7itAwsXAmyT9w433AC89JLHZ0a4gsOyZcDkyda1YD28H5o9O/w+RENO+XCI3FWQ4BA5lqpJBKKCQKwJDgyLddxx1k1FYqLlxbq+3kLJZRcMvWhbQeywA8BJzDetXw/ceCPQrx/QoYPnBoUiBes8+GBr8vT3oMsHYrsMbz4CJZp0Ml+nTgDLOBMnd/aR1hesg46weANlt3/44QDf6ISbGDZ05EjAdqxliy387NkTOPVU64bAX32bNgG33w5sv71nXHZ59r93b2DcOMAfC7s+/oZ22skzBrs8x0jOvBmxj/lzGklRY+JEgNfL3xi22Qa49dbgAo/dl2j4lOAQDVdBfRABEQhGINYEB46FooA9lwwZAjACkp3oFHL4cOs8zwUS2ykGMJ99n2DXx/mO8yXnrI0b7Vq9P48+2pon+VAeKPHhn3Vx23ffhnM5X4iwbS4L5YuL/v2tPjN/jx4A549wE5eLXHklsPXW
}
},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction\n",
"\n",
"At present, you can choose from three popular open source Deep Learning libraries:\n",
"\n",
"- TensorFlow, \n",
"- Microsoft Cognitive Toolkit (CNTK), \n",
"- Theano. \n",
"\n",
"Therefore, to avoid any confusion, we will refer to Keras implementation as multi-backend Keras.\n",
"\n",
"TensorFlow itself now comes bundled with its own Keras implementation,tf.keras. It only supports TensorFlow as the backend.\n",
"\n",
"![image.png](attachment:image.png)\n",
"\n",
"This short introduction uses Tensorflow Keras to:\n",
"\n",
"- Build a neural network that classifies images.\n",
"- Train this neural network.\n",
"- And, finally, evaluate the accuracy of the model.\n",
"\n",
"# Reference\n",
"https://www.tensorflow.org/tutorials/quickstart/beginner"
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 1,
2021-12-14 00:35:39 +00:00
"metadata": {
"_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
"_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5"
},
"outputs": [],
"source": [
"# This Python 3 environment comes with many helpful analytics libraries installed\n",
"# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n",
"# For example, here's several helpful packages to load in \n",
"\n",
"import numpy as np # linear algebra\n",
"import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n",
"\n",
"# Input data files are available in the \"../input/\" directory.\n",
"# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n",
"\n",
"import os\n",
"for dirname, _, filenames in os.walk('/kaggle/input'):\n",
" for filename in filenames:\n",
" print(os.path.join(dirname, filename))\n",
"\n",
"# Any results you write to the current directory are saved as output."
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 2,
2021-12-14 00:35:39 +00:00
"metadata": {},
2021-12-14 00:38:45 +00:00
"outputs": [],
2021-12-14 00:35:39 +00:00
"source": [
"import tensorflow as tf"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## To Check GPU Availability in Tensorflow"
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 3,
2021-12-14 00:35:39 +00:00
"metadata": {
"_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0",
"_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a"
},
"outputs": [
{
2021-12-14 00:38:45 +00:00
"name": "stdout",
2021-12-14 00:35:39 +00:00
"output_type": "stream",
"text": [
2021-12-14 00:38:45 +00:00
"Name: /physical_device:GPU:0 Type: GPU\n"
2021-12-14 00:35:39 +00:00
]
}
],
"source": [
"\n",
"gpus = tf.config.experimental.list_physical_devices('GPU')\n",
"for gpu in gpus:\n",
" print(\"Name:\", gpu.name, \" Type:\", gpu.device_type)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Listing Devices including GPU's with Tensorflow"
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 4,
2021-12-14 00:35:39 +00:00
"metadata": {},
"outputs": [
{
2021-12-14 00:38:45 +00:00
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:36:17.947416: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"2021-12-13 18:36:17.948346: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1510] Created device /device:GPU:0 with 7676 MB memory: -> device: 0, name: AMD Radeon RX 6600 XT, pci bus id: 0000:08:00.0\n"
2021-12-14 00:35:39 +00:00
]
2021-12-14 00:38:45 +00:00
},
{
"data": {
"text/plain": [
"[name: \"/device:CPU:0\"\n",
" device_type: \"CPU\"\n",
" memory_limit: 268435456\n",
" locality {\n",
" }\n",
" incarnation: 4131910275298190244,\n",
" name: \"/device:GPU:0\"\n",
" device_type: \"GPU\"\n",
" memory_limit: 8048869376\n",
" locality {\n",
" bus_id: 2\n",
" numa_node: 1\n",
" links {\n",
" }\n",
" }\n",
" incarnation: 8120473677084580141\n",
" physical_device_desc: \"device: 0, name: AMD Radeon RX 6600 XT, pci bus id: 0000:08:00.0\"]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
2021-12-14 00:35:39 +00:00
}
],
"source": [
"\n",
"from tensorflow.python.client import device_lib\n",
"\n",
"device_lib.list_local_devices()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# To Check GPU in Tensorflow"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "Error",
"evalue": "Session cannot generate requests",
"output_type": "error",
"traceback": [
"Error: Session cannot generate requests",
"at w.executeCodeCell (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:302205)",
"at w.execute (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:301589)",
"at w.start (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:297159)",
"at processTicksAndRejections (internal/process/task_queues.js:93:5)",
"at async t.CellExecutionQueue.executeQueuedCells (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:312368)",
"at async t.CellExecutionQueue.start (/home/ta180m/.vscode-oss/extensions/ms-toolsai.jupyter-2021.10.100/out/client/extension.js:52:311908)"
]
}
],
"source": [
"\n",
"tf.test.is_gpu_available()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load MNiST Dataset"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"mnist = tf.keras.datasets.mnist\n",
"\n",
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Pre-processing of Training and Test Datasets"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"x_train, x_test = x_train / 255.0, x_test / 255.0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create Sequential Model Using Tensorflow Keras\n",
"\n",
"Architecture of the Network is :-\n",
"\n",
"1). Input layer for 28x28 images in MNiST dataset\n",
"\n",
"2). Dense layer with 128 neurons and ReLU activation function\n",
"\n",
"3). Output layer with 10 neurons for classification of input images as one of ten digits(0 to 9)"
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 7,
2021-12-14 00:35:39 +00:00
"metadata": {},
2021-12-14 00:38:45 +00:00
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:36:29.743574: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1510] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 7676 MB memory: -> device: 0, name: AMD Radeon RX 6600 XT, pci bus id: 0000:08:00.0\n"
]
}
],
2021-12-14 00:35:39 +00:00
"source": [
"model = tf.keras.models.Sequential([\n",
" tf.keras.layers.Flatten(input_shape=(28, 28)),\n",
" tf.keras.layers.Dense(128, activation='relu'),\n",
" tf.keras.layers.Dropout(0.2),\n",
" tf.keras.layers.Flatten(input_shape=(100, 100)),\n",
" tf.keras.layers.Dense(1024, activation='relu'),\n",
" tf.keras.layers.Flatten(input_shape=(100, 100)),\n",
" tf.keras.layers.Dense(1024, activation='relu'),\n",
" tf.keras.layers.Dense(10)\n",
"])"
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 8,
2021-12-14 00:35:39 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2021-12-14 00:38:45 +00:00
"array([[ 0.05019438, -0.11693908, 0.0457226 , -0.10117609, 0.07739688,\n",
" -0.15473695, -0.09796654, -0.06173493, -0.08286384, 0.1133035 ]],\n",
2021-12-14 00:35:39 +00:00
" dtype=float32)"
]
},
2021-12-14 00:38:45 +00:00
"execution_count": 8,
2021-12-14 00:35:39 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predictions = model(x_train[:1]).numpy()\n",
"predictions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Creating Loss Function"
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 9,
2021-12-14 00:35:39 +00:00
"metadata": {},
"outputs": [],
"source": [
"loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Compile the Model Designed Earlier\n",
"\n",
"Before the model is ready for training, it needs a few more settings. These are added during the model's compile step:\n",
"\n",
"- Loss function \n",
"This measures how accurate the model is during training. You want to minimize this function to \"steer\" the model in the right direction.\n",
"\n",
"- Optimizer \n",
"This is how the model is updated based on the data it sees and its loss function.\n",
"\n",
"- Metrics\n",
"Used to monitor the training and testing steps. The following example uses accuracy, the fraction of the images that are correctly classified."
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 10,
2021-12-14 00:35:39 +00:00
"metadata": {},
"outputs": [],
"source": [
"model.compile(optimizer='adam',\n",
" loss=loss_fn,\n",
" metrics=['accuracy'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Training and Validation\n",
"\n",
"The Model.fit method adjusts the model parameters to minimize the loss:\n"
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 12,
2021-12-14 00:35:39 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/10\n",
2021-12-14 00:38:45 +00:00
" 107/1875 [>.............................] - ETA: 2s - loss: 0.0625 - accuracy: 0.9807"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:37:40.224182: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:37:40.226497: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:37:40.228452: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1875/1875 [==============================] - 3s 2ms/step - loss: 0.0572 - accuracy: 0.9823\n",
2021-12-14 00:35:39 +00:00
"Epoch 2/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 1ms/step - loss: 0.0556 - accuracy: 0.9830\n",
2021-12-14 00:35:39 +00:00
"Epoch 3/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 2ms/step - loss: 0.0520 - accuracy: 0.9845\n",
2021-12-14 00:35:39 +00:00
"Epoch 4/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 1ms/step - loss: 0.0505 - accuracy: 0.9851\n",
2021-12-14 00:35:39 +00:00
"Epoch 5/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 5s 3ms/step - loss: 0.0506 - accuracy: 0.9847\n",
2021-12-14 00:35:39 +00:00
"Epoch 6/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 1ms/step - loss: 0.0479 - accuracy: 0.9858\n",
2021-12-14 00:35:39 +00:00
"Epoch 7/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 2ms/step - loss: 0.0474 - accuracy: 0.9865\n",
2021-12-14 00:35:39 +00:00
"Epoch 8/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 1ms/step - loss: 0.0474 - accuracy: 0.9866\n",
2021-12-14 00:35:39 +00:00
"Epoch 9/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 1ms/step - loss: 0.0463 - accuracy: 0.9867\n",
2021-12-14 00:35:39 +00:00
"Epoch 10/10\n",
2021-12-14 00:38:45 +00:00
"1875/1875 [==============================] - 3s 1ms/step - loss: 0.0434 - accuracy: 0.9876\n"
2021-12-14 00:35:39 +00:00
]
},
{
"data": {
"text/plain": [
2021-12-14 00:38:45 +00:00
"<keras.callbacks.History at 0x7fd8c0525490>"
2021-12-14 00:35:39 +00:00
]
},
2021-12-14 00:38:45 +00:00
"execution_count": 12,
2021-12-14 00:35:39 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.fit(x_train, y_train, epochs=10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Model.evaluate method checks the models performance, usually on a \"Validation-set\" or \"Test-set\"."
]
},
{
"cell_type": "code",
2021-12-14 00:38:45 +00:00
"execution_count": 13,
2021-12-14 00:35:39 +00:00
"metadata": {},
"outputs": [
2021-12-14 00:38:45 +00:00
{
"name": "stderr",
"output_type": "stream",
"text": [
"2021-12-13 18:38:18.485616: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:38:18.489485: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:38:18.492379: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n",
"2021-12-13 18:38:18.559492: I tensorflow/core/common_runtime/gpu_fusion_pass.cc:507] ROCm Fusion is enabled.\n"
]
},
2021-12-14 00:35:39 +00:00
{
"name": "stdout",
"output_type": "stream",
"text": [
2021-12-14 00:38:45 +00:00
"313/313 - 0s - loss: 0.0782 - accuracy: 0.9808\n"
2021-12-14 00:35:39 +00:00
]
},
{
"data": {
"text/plain": [
2021-12-14 00:38:45 +00:00
"[0.07822339236736298, 0.9807999730110168]"
2021-12-14 00:35:39 +00:00
]
},
2021-12-14 00:38:45 +00:00
"execution_count": 13,
2021-12-14 00:35:39 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"model.evaluate(x_test, y_test, verbose=2)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Please Upvote,Comment, Fork and Share to Help me with my efforts to help the community."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}