From d8eaafe3c2baec13ba99dca7f571e96e488bffc0 Mon Sep 17 00:00:00 2001 From: ankup007 Date: Mon, 1 Apr 2024 02:56:56 +0000 Subject: [PATCH] my practice --- chapter02_mathematical-building-blocks.ipynb | 867 ++++++++++++++++--- 1 file changed, 736 insertions(+), 131 deletions(-) diff --git a/chapter02_mathematical-building-blocks.ipynb b/chapter02_mathematical-building-blocks.ipynb index 01edc9becc..68c7a4486c 100644 --- a/chapter02_mathematical-building-blocks.ipynb +++ b/chapter02_mathematical-building-blocks.ipynb @@ -6,7 +6,11 @@ "colab_type": "text" }, "source": [ - "This is a companion notebook for the book [Deep Learning with Python, Second Edition](https://www.manning.com/books/deep-learning-with-python-second-edition?a_aid=keras&a_bid=76564dff). For readability, it only contains runnable code blocks and section titles, and omits everything else in the book: text paragraphs, figures, and pseudocode.\n\n**If you want to be able to follow what's going on, I recommend reading the notebook side by side with your copy of the book.**\n\nThis notebook was generated for TensorFlow 2.6." + "This is a companion notebook for the book [Deep Learning with Python, Second Edition](https://www.manning.com/books/deep-learning-with-python-second-edition?a_aid=keras&a_bid=76564dff). For readability, it only contains runnable code blocks and section titles, and omits everything else in the book: text paragraphs, figures, and pseudocode.\n", + "\n", + "**If you want to be able to follow what's going on, I recommend reading the notebook side by side with your copy of the book.**\n", + "\n", + "This notebook was generated for TensorFlow 2.6." ] }, { @@ -38,11 +42,23 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 1, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-03-31 10:26:01.169166: I external/local_tsl/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n", + "2024-03-31 10:26:02.626567: I external/local_tsl/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n", + "2024-03-31 10:26:06.107060: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", + "To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n", + "2024-03-31 10:26:10.714211: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n" + ] + } + ], "source": [ "from tensorflow.keras.datasets import mnist\n", "(train_images, train_labels), (test_images, test_labels) = mnist.load_data()" @@ -50,66 +66,132 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 2, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(60000, 28, 28)" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "train_images.shape" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 3, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "60000" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "len(train_labels)" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 4, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "array([5, 0, 4, ..., 5, 6, 8], dtype=uint8)" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "train_labels" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 5, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(10000, 28, 28)" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "test_images.shape" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 6, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "len(test_labels)" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 7, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "array([7, 2, 1, ..., 4, 5, 6], dtype=uint8)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "test_labels" ] @@ -125,7 +207,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 8, "metadata": { "colab_type": "code" }, @@ -150,7 +232,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 9, "metadata": { "colab_type": "code" }, @@ -172,7 +254,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 10, "metadata": { "colab_type": "code" }, @@ -195,11 +277,45 @@ }, { "cell_type": "code", - "execution_count": 0, - "metadata": { - "colab_type": "code" - }, - "outputs": [], + "execution_count": 11, + "metadata": { + "colab_type": "code" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Epoch 1/5\n", + "\u001b[1m162/469\u001b[0m \u001b[32m━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━\u001b[0m \u001b[1m0s\u001b[0m 3ms/step - accuracy: 0.8090 - loss: 0.6733" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m2s\u001b[0m 3ms/step - accuracy: 0.8746 - loss: 0.4436\n", + "Epoch 2/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9658 - loss: 0.1142\n", + "Epoch 3/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9792 - loss: 0.0730\n", + "Epoch 4/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9849 - loss: 0.0514\n", + "Epoch 5/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9893 - loss: 0.0370\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "model.fit(train_images, train_labels, epochs=5, batch_size=128)" ] @@ -215,11 +331,31 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 12, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 28ms/step\n" + ] + }, + { + "data": { + "text/plain": [ + "array([2.7841112e-09, 2.0664112e-10, 1.1490897e-06, 2.4335416e-06,\n", + " 9.0371374e-13, 4.1103667e-09, 2.0538105e-13, 9.9999601e-01,\n", + " 1.6185471e-08, 3.9793741e-07], dtype=float32)" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "test_digits = test_images[0:10]\n", "predictions = model.predict(test_digits)\n", @@ -228,33 +364,66 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 13, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "7" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "predictions[0].argmax()" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 14, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.999996" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "predictions[0][7]" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 15, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "7" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "test_labels[0]" ] @@ -270,11 +439,20 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 16, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1m313/313\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 950us/step - accuracy: 0.9781 - loss: 0.0770\n", + "test_acc: 0.9807000160217285\n" + ] + } + ], "source": [ "test_loss, test_acc = model.evaluate(test_images, test_labels)\n", "print(f\"test_acc: {test_acc}\")" @@ -300,11 +478,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 17, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "array(12)" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import numpy as np\n", "x = np.array(12)\n", @@ -313,11 +502,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 18, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x.ndim" ] @@ -333,11 +533,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 19, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "array([12, 3, 6, 14, 7])" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x = np.array([12, 3, 6, 14, 7])\n", "x" @@ -345,11 +556,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 20, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x.ndim" ] @@ -365,11 +587,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 21, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x = np.array([[5, 78, 2, 34, 0],\n", " [6, 79, 3, 35, 1],\n", @@ -388,11 +621,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 22, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x = np.array([[[5, 78, 2, 34, 0],\n", " [6, 79, 3, 35, 1],\n", @@ -417,7 +661,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 23, "metadata": { "colab_type": "code" }, @@ -429,33 +673,66 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 24, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "train_images.ndim" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 25, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(60000, 28, 28)" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "train_images.shape" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 26, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "dtype('uint8')" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "train_images.dtype" ] @@ -471,11 +748,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 27, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaAAAAGdCAYAAABU0qcqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAbYklEQVR4nO3df2zU9R3H8deB9ERsryulvZ4ULKigAl2G0jUq4mgoXUZAyCbqFjAEIitG7JymTkSdWSdmzOgq/rPB3ESYiUD0DxxW286tsIESxn50tOkEAi1I0l4pUhj97I+G2w6K8D3u+u4dz0fyTejd99N78/XSp1/67bc+55wTAAD9bJD1AACAKxMBAgCYIEAAABMECABgggABAEwQIACACQIEADBBgAAAJq6yHuBcPT09OnTokNLT0+Xz+azHAQB45JxTZ2enQqGQBg268HnOgAvQoUOHlJ+fbz0GAOAyHThwQCNHjrzg8wMuQOnp6ZJ6B8/IyDCeBgDgVTgcVn5+fuTr+YUkLEDV1dV66aWX1NraqsLCQr366quaMmXKRded/We3jIwMAgQASexi30ZJyEUIGzduVEVFhVauXKlPPvlEhYWFKi0t1ZEjRxLxcgCAJJSQAK1evVqLFy/WQw89pFtuuUWvv/66rrnmGv3qV79KxMsBAJJQ3AN06tQp7dq1SyUlJf97kUGDVFJSooaGhvP27+7uVjgcjtoAAKkv7gH6/PPPdebMGeXm5kY9npubq9bW1vP2r6qqUiAQiGxcAQcAVwbzH0StrKxUR0dHZDtw4ID1SACAfhD3q+Cys7M1ePBgtbW1RT3e1tamYDB43v5+v19+vz/eYwAABri4nwGlpaVp8uTJqqmpiTzW09OjmpoaFRcXx/vlAABJKiE/B1RRUaEFCxbotttu05QpU/Tyyy+rq6tLDz30UCJeDgCQhBISoPvuu09Hjx7VM888o9bWVn31q1/V1q1bz7swAQBw5fI555z1EP8vHA4rEAioo6ODOyEAQBK61K/j5lfBAQCuTAQIAGCCAAEATBAgAIAJAgQAMEGAAAAmCBAAwAQBAgCYIEAAABMECABgggABAEwQIACACQIEADBBgAAAJggQAMAEAQIAmCBAAAATBAgAYIIAAQBMECAAgAkCBAAwQYAAACYIEADABAECAJggQAAAEwQIAGCCAAEATBAgAIAJAgQAMEGAAAAmCBAAwAQBAgCYIEAAABMECABgggABAEwQIACACQIEADBBgAAAJggQAMAEAQIAmCBAAAATBAgAYIIAAQBMECAAgAkCBAAwQYAAACYIEADABAECAJggQAAAEwQIAGCCAAEATBAgAIAJAgQAMEGAAAAmCBAAwETcA/Tss8/K5/NFbePHj4/3ywAAktxVifikt956qz744IP/vchVCXkZAEASS0gZrrrqKgWDwUR8agBAikjI94D27dunUCikMWPG6MEHH9T+/fsvuG93d7fC4XDUBgBIfXEPUFFRkdatW6etW7dqzZo1amlp0V133aXOzs4+96+qqlIgEIhs+fn58R4JADAA+ZxzLpEv0N7ertGjR2v16tVatGjRec93d3eru7s78nE4HFZ+fr46OjqUkZGRyNEAAAkQDocVCAQu+nU84VcHZGZm6qabblJTU1Ofz/v9fvn9/kSPAQAYYBL+c0DHjx9Xc3Oz8vLyEv1SAIAkEvcAPf7446qrq9O///1v/elPf9K9996rwYMH6/7774/3SwEAkljc/wnu4MGDuv/++3Xs2DGNGDFCd955p7Zv364RI0bE+6UAAEks7gHasGFDvD8lACAFcS84AIAJAgQAMEGAAAAmCBAAwAQBAgCYIEAAABMECABgggABAEwQIACACQIEADBBgAAAJggQAMBEwn8hHZBMduzY4XnNb37zG89r6uvrPa/Zu3ev5zWx+tnPfuZ5TSgU8rzmD3/4g+c13/ve9zyvKSoq8rwGiccZEADABAECAJggQAAAEwQIAGCCAAEATBAgAIAJAgQAMEGAAAAmCBAAwAQBAgCYIEAAABMECABgggABAExwN2ykpI0bN8a07tFHH/W85ujRo57XOOc8r5k2bZrnNZ9//rnnNZL0+OOPx7TOq1iOQyx/pw0bNnheg8TjDAgAYIIAAQBMECAAgAkCBAAwQYAAACY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qiEuxYcMG5/f73bp169zf//53t2TJEpeZmelaW1utR+tXP/jBD1xtba1raWlxf/zjH11JSYnLzs52R44csR4toTo7O92nn37qPv30UyfJrV692n366afus88+c84599Of/tRlZma6LVu2uD179rjZs2e7goIC98UXXxhPHl9fdhw6Ozvd448/7hoaGlxLS4v74IMP3Ne+9jV34403upMnT1qPHjdLly51gUDA1dbWusOHD0e2EydORPZ5+OGH3ahRo9yHH37odu7c6YqLi11xcbHh1PF3sePQ1NTknn/+ebdz507X0tLitmzZ4saMGeOmTp1qPHm0pAiQc869+uqrbtSoUS4tLc1NmTLFbd++3Xqkfnffffe5vLw8l5aW5q677jp33333uaamJuuxEu6jjz5yks7bFixY4JzrvRR7xYoVLjc31/n9fjd9+nTX2NhoO3QCfNlxOHHihJsxY4YbMWKEGzJkiBs9erRbvHhxyv1PWl9/f0lu7dq1kX2++OIL9/3vf9995Stfcddcc42799573eHDh+2GToCLHYf9+/e7qVOnuqysLOf3+90NN9zgfvjDH7qOjg7bwc/Br2MAAJgY8N8DAgCkJgIEADBBgAAAJggQAMAEAQIAmCBAAAATBAgAYIIAAQBMECAAgAkCBAAwQYAAACYIEADAxH8BB0q1GdOY6GMAAAAASUVORK5CYII=", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import matplotlib.pyplot as plt\n", "digit = train_images[4]\n", @@ -485,11 +773,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 28, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "9" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "train_labels[4]" ] @@ -505,11 +804,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 29, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(90, 28, 28)" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "my_slice = train_images[10:100]\n", "my_slice.shape" @@ -517,11 +827,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 30, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(90, 28, 28)" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "my_slice = train_images[10:100, :, :]\n", "my_slice.shape" @@ -529,11 +850,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 31, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(90, 28, 28)" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "my_slice = train_images[10:100, 0:28, 0:28]\n", "my_slice.shape" @@ -541,7 +873,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 32, "metadata": { "colab_type": "code" }, @@ -552,7 +884,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 33, "metadata": { "colab_type": "code" }, @@ -572,7 +904,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 34, "metadata": { "colab_type": "code" }, @@ -583,7 +915,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 35, "metadata": { "colab_type": "code" }, @@ -594,7 +926,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 36, "metadata": { "colab_type": "code" }, @@ -669,7 +1001,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 37, "metadata": { "colab_type": "code" }, @@ -686,7 +1018,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 38, "metadata": { "colab_type": "code" }, @@ -704,11 +1036,19 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 39, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Took: 0.00 s\n" + ] + } + ], "source": [ "import time\n", "\n", @@ -724,11 +1064,19 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 40, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Took: 1.46 s\n" + ] + } + ], "source": [ "t0 = time.time()\n", "for _ in range(1000):\n", @@ -748,7 +1096,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 41, "metadata": { "colab_type": "code" }, @@ -761,7 +1109,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 42, "metadata": { "colab_type": "code" }, @@ -772,7 +1120,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 43, "metadata": { "colab_type": "code" }, @@ -783,7 +1131,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 44, "metadata": { "colab_type": "code" }, @@ -802,7 +1150,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 45, "metadata": { "colab_type": "code" }, @@ -825,7 +1173,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 46, "metadata": { "colab_type": "code" }, @@ -838,7 +1186,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 47, "metadata": { "colab_type": "code" }, @@ -856,7 +1204,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 48, "metadata": { "colab_type": "code" }, @@ -875,7 +1223,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 49, "metadata": { "colab_type": "code" }, @@ -890,7 +1238,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 50, "metadata": { "colab_type": "code" }, @@ -920,7 +1268,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 51, "metadata": { "colab_type": "code" }, @@ -931,11 +1279,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 52, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 2)" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x = np.array([[0., 1.],\n", " [2., 3.],\n", @@ -945,11 +1304,27 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 53, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "array([[0.],\n", + " [1.],\n", + " [2.],\n", + " [3.],\n", + " [4.],\n", + " [5.]])" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x = x.reshape((6, 1))\n", "x" @@ -957,11 +1332,22 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 54, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(20, 300)" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x = np.zeros((300, 20))\n", "x = np.transpose(x)\n", @@ -1060,7 +1446,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 55, "metadata": { "colab_type": "code" }, @@ -1075,7 +1461,47 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grad_of_y_wrt_x" + ] + }, + { + "cell_type": "code", + "execution_count": 58, "metadata": { "colab_type": "code" }, @@ -1083,13 +1509,35 @@ "source": [ "x = tf.Variable(tf.random.uniform((2, 2)))\n", "with tf.GradientTape() as tape:\n", - " y = 2 * x + 3\n", + " y = 3 * x + 3\n", "grad_of_y_wrt_x = tape.gradient(y, x)" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grad_of_y_wrt_x" + ] + }, + { + "cell_type": "code", + "execution_count": 60, "metadata": { "colab_type": "code" }, @@ -1103,6 +1551,73 @@ "grad_of_y_wrt_W_and_b = tape.gradient(y, [W, b])" ] }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[,\n", + " ]" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grad_of_y_wrt_W_and_b" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "W" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x" + ] + }, { "cell_type": "markdown", "metadata": { @@ -1114,7 +1629,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 64, "metadata": { "colab_type": "code" }, @@ -1129,7 +1644,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 65, "metadata": { "colab_type": "code" }, @@ -1143,7 +1658,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 66, "metadata": { "colab_type": "code" }, @@ -1156,11 +1671,38 @@ }, { "cell_type": "code", - "execution_count": 0, - "metadata": { - "colab_type": "code" - }, - "outputs": [], + "execution_count": 67, + "metadata": { + "colab_type": "code" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Epoch 1/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m2s\u001b[0m 3ms/step - accuracy: 0.8718 - loss: 0.4433\n", + "Epoch 2/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9668 - loss: 0.1170\n", + "Epoch 3/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9795 - loss: 0.0711\n", + "Epoch 4/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9844 - loss: 0.0516\n", + "Epoch 5/5\n", + "\u001b[1m469/469\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 3ms/step - accuracy: 0.9892 - loss: 0.0362\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "model.fit(train_images, train_labels, epochs=5, batch_size=128)" ] @@ -1185,7 +1727,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 68, "metadata": { "colab_type": "code" }, @@ -1224,7 +1766,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 69, "metadata": { "colab_type": "code" }, @@ -1250,7 +1792,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 70, "metadata": { "colab_type": "code" }, @@ -1274,7 +1816,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 71, "metadata": { "colab_type": "code" }, @@ -1309,7 +1851,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 72, "metadata": { "colab_type": "code" }, @@ -1328,7 +1870,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 73, "metadata": { "colab_type": "code" }, @@ -1343,7 +1885,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 74, "metadata": { "colab_type": "code" }, @@ -1368,7 +1910,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 75, "metadata": { "colab_type": "code" }, @@ -1387,11 +1929,78 @@ }, { "cell_type": "code", - "execution_count": 0, - "metadata": { - "colab_type": "code" - }, - "outputs": [], + "execution_count": 76, + "metadata": { + "colab_type": "code" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Epoch 0\n", + "loss at batch 0: 6.04\n", + "loss at batch 100: 2.26\n", + "loss at batch 200: 2.23\n", + "loss at batch 300: 2.09\n", + "loss at batch 400: 2.23\n", + "Epoch 1\n", + "loss at batch 0: 1.90\n", + "loss at batch 100: 1.89\n", + "loss at batch 200: 1.84\n", + "loss at batch 300: 1.71\n", + "loss at batch 400: 1.83\n", + "Epoch 2\n", + "loss at batch 0: 1.57\n", + "loss at batch 100: 1.58\n", + "loss at batch 200: 1.51\n", + "loss at batch 300: 1.42\n", + "loss at batch 400: 1.50\n", + "Epoch 3\n", + "loss at batch 0: 1.31\n", + "loss at batch 100: 1.34\n", + "loss at batch 200: 1.23\n", + "loss at batch 300: 1.20\n", + "loss at batch 400: 1.26\n", + "Epoch 4\n", + "loss at batch 0: 1.12\n", + "loss at batch 100: 1.15\n", + "loss at batch 200: 1.04\n", + "loss at batch 300: 1.04\n", + "loss at batch 400: 1.09\n", + "Epoch 5\n", + "loss at batch 0: 0.98\n", + "loss at batch 100: 1.02\n", + "loss at batch 200: 0.90\n", + "loss at batch 300: 0.92\n", + "loss at batch 400: 0.97\n", + "Epoch 6\n", + "loss at batch 0: 0.87\n", + "loss at batch 100: 0.91\n", + "loss at batch 200: 0.80\n", + "loss at batch 300: 0.83\n", + "loss at batch 400: 0.89\n", + "Epoch 7\n", + "loss at batch 0: 0.79\n", + "loss at batch 100: 0.83\n", + "loss at batch 200: 0.72\n", + "loss at batch 300: 0.76\n", + "loss at batch 400: 0.82\n", + "Epoch 8\n", + "loss at batch 0: 0.73\n", + "loss at batch 100: 0.76\n", + "loss at batch 200: 0.66\n", + "loss at batch 300: 0.71\n", + "loss at batch 400: 0.77\n", + "Epoch 9\n", + "loss at batch 0: 0.68\n", + "loss at batch 100: 0.71\n", + "loss at batch 200: 0.61\n", + "loss at batch 300: 0.66\n", + "loss at batch 400: 0.73\n" + ] + } + ], "source": [ "from tensorflow.keras.datasets import mnist\n", "(train_images, train_labels), (test_images, test_labels) = mnist.load_data()\n", @@ -1415,11 +2024,19 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 77, "metadata": { "colab_type": "code" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "accuracy: 0.81\n" + ] + } + ], "source": [ "predictions = model(test_images)\n", "predictions = predictions.numpy()\n", @@ -1447,23 +2064,11 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "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.7.0" } }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +}