├── .gitignore ├── 10_gpu_benchmarking ├── DGX_performance │ ├── DGX_benchmarking_on_ngc_container.ipynb │ ├── dgx_benchamrking_on_local_python_installation.ipynb │ ├── dgx_benchamrking_tf_mirrored_stratergy.ipynb │ └── small_images.jpg ├── Exercise │ ├── exercise_fashion_mnist_gpu_benchmarking.ipynb │ └── exercise_solution.ipynb ├── gpu_performance_test_small_image_classification.ipynb └── small_images.jpg ├── 11_chrun_prediction ├── churn.ipynb └── customer_churn.csv ├── 12_precision_recall └── 12_precision_recall.ipynb ├── 13_dropout_layer ├── dropout_regularization_ann.ipynb └── sonar_dataset.csv ├── 14_imbalanced ├── Handling Imbalanced Data In Customer Churn Using ANN │ ├── Bank Turnover Customer Churn Using ANN.ipynb │ └── Churn_Modelling.csv ├── customer_churn.csv ├── handling_imbalanced_data.ipynb ├── handling_imbalanced_data_exercise.md └── handling_imbalanced_data_exercise_solution_telecom_churn.ipynb ├── 16_cnn_cifar10_small_image_classification ├── cnn_cifar10_dataset.ipynb ├── cnn_mnist_exercise_solution.ipynb ├── digits_nn.jpg └── small_images.jpg ├── 17_data_augmentation ├── cnn_flower_image_classification_data_augmentations.ipynb └── daisy2.JPG ├── 18_transfer_learning ├── ImageNetLabels.txt ├── cnn_transfer_learning.ipynb └── goldfish.jpg ├── 1_digits_recognition ├── digits_nn.jpg └── digits_recognition_neural_network.ipynb ├── 1_keras_fashion_mnist_neural_net ├── 1_keras_fashion_mnist.ipynb ├── Exercise │ └── 1_keras_sequential_exercise.ipynb ├── Slide1.PNG ├── Slide2.PNG ├── classlabels.JPG ├── fashion_neural_net.png └── fmnist.png ├── 22_word_embedding └── supervised_word_embeddings.ipynb ├── 2_activation_functions └── 2_activation_functions.ipynb ├── 3_derivatives ├── derivatives_answer.jpg ├── derivatives_exercise.md ├── derivatives_exercise_solution.md └── derivatives_question.jpg ├── 42_word2vec_gensim ├── 42_word2vec_gensim.ipynb └── 42_word2vec_gensim_exercise_solution.ipynb ├── 43_distributed_training ├── dgx_benchamrking_tf_mirrored_stratergy.ipynb └── small_images.jpg ├── 43_text_classification_rnn └── rnn_text_classification.ipynb ├── 44_tf_data_pipeline ├── Exercise │ ├── reviews │ │ ├── negative │ │ │ ├── neg_1.txt │ │ │ ├── neg_2.txt │ │ │ └── neg_3.txt │ │ └── positive │ │ │ ├── pos_1.txt │ │ │ ├── pos_2.txt │ │ │ └── pos_3.txt │ ├── tf_data_pipeline_exercise.md │ └── tf_data_pipeline_exercise_solution.ipynb ├── images │ ├── cat │ │ ├── 20 Reasons Why Cats Make the Best Pets....jpg │ │ ├── 7 Foods Your Cat Can_t Eat.jpg │ │ ├── A cat appears to have caught the....jpg │ │ ├── Adopt-A-Cat Month® - American Humane....jpg │ │ ├── All About Your Cat_s Tongue.jpg │ │ ├── Alley Cat Allies _ An Advocacy....jpg │ │ ├── Are Cats Domesticated_ _ The New Yorker.jpg │ │ ├── Cat Advice _ Collecting a Urine Sample....jpg │ │ ├── Cat Throwing Up_ Normal or Cause for....jpg │ │ ├── Cat intelligence - Wikipedia.jpg │ │ ├── Cats Care About People More Than Food....jpg │ │ ├── Cats _ The Humane Society of the United....jpg │ │ ├── Cats really do need their humans_ even....jpg │ │ ├── China_s First Cloned Kitten_ Garlic....png │ │ ├── Famous Cat Performances in Movies_ Ranked.jpg │ │ ├── Giving cats food with an antibody may....jpg │ │ ├── Home_ sweet home_ How to bring an....jpg │ │ ├── How to Determine Your Cat_s Age.jpg │ │ ├── How to buy the best cat food_ according....jpg │ │ ├── International Cat Care _ The ultimate....jpg │ │ ├── Is My Cat Normal_.jpg │ │ ├── Learn what to do with Stray and Feral....jpg │ │ ├── New Cat Checklist 2021_ Supplies for....jpg │ │ ├── Orlando Cat Café.png │ │ ├── Pet Insurance for Cats & Kittens _ Petplan.png │ │ ├── Reality check_ Can cat poop cause....jpg │ │ ├── Soon_ the internet will make its own....jpg │ │ ├── Stray Cat Alliance » Building a No Kill....jpg │ │ ├── Texas lawyer accidentally uses cat....jpg │ │ ├── The 10 Best Types of Cat _ Britannica.jpg │ │ ├── The Cat Health Checklist_ Everything....jpg │ │ ├── The Joys of Owning a Cat - HelpGuide.org.jpg │ │ ├── The Science-Backed Benefits of Being a....jpg │ │ ├── Thinking of getting a cat....png │ │ ├── Urine Marking in Cats _ ASPCA.jpg │ │ ├── Want your cat to stay in purrrfect....jpg │ │ ├── What does the COVID-19 summer surge....jpg │ │ ├── What to do if your cat is marking....jpg │ │ ├── Why Cats Sniff Rear Ends _ VCA Animal....png │ │ └── Why Do Cats Hate Water_ _ Britannica.jpg │ └── dog │ │ ├── 10 Teacup Dog Breeds for Tiny Canine Lovers.jpg │ │ ├── 100_ Dogs Pictures _ Download Free....jpg │ │ ├── 11 Things Humans Do That Dogs Hate.jpg │ │ ├── 15 Amazing Facts About Dogs That Will....jpg │ │ ├── 20 must-have products for new dog owners.jpg │ │ ├── 25 Best Small Dog Breeds — Cute and....jpg │ │ ├── 25 Low-Maintenance Dog Breeds for....jpg │ │ ├── 2nd pet dog tests positive for COVID-19....jpg │ │ ├── 356 Free Dog Stock Photos - CC0 Images.jpg │ │ ├── 45 Best Large Dog Breeds - Top Big Dogs_yyth....jpg │ │ ├── 50 Cutest Dog Breeds as Puppies....jpg │ │ ├── 50 dog breeds and their history that....jpg │ │ ├── 66 gifts for dogs or dog lovers to get_yythk....jpg │ │ ├── 7 Tips on Canine Body Language _ ASPCApro.jpg │ │ ├── 8 amazing Indian dog breeds that....png │ │ ├── 9 Reasons to Own a Dog.jpg │ │ ├── AKC Pet Insurance _ Health Insurance....png │ │ ├── Aggression in dogs _ Animal Humane Society.jpg │ │ ├── Ancient dog DNA reveals 11_000 years of....jpg │ │ ├── Are Dogs Really Color-Blind_ _ Britannica.jpg │ │ ├── Best Dog & Puppy Health Insurance Plans....jpg │ │ ├── Best Hypoallergenic Dogs [Updated....jpg │ │ ├── Body Condition Score....jpg │ │ ├── Calculate Your Dog_s Age With This New....jpg │ │ ├── Canine Mind....jpg │ │ ├── Carolina Dog Dog Breed Information....jpg │ │ ├── Cats and Dogs.jpg │ │ ├── Colitis in Dogs _ VCA Animal Hospital.jpg │ │ ├── Common Dog Breeds and Their Health Issues.jpg │ │ ├── Dog - Role in human societies _ Britannica.jpg │ │ ├── Dog Breed Chart....jpg │ │ ├── Dog Breeds Banned By Home Insurance....jpg │ │ ├── Dog collars _ The Humane Society of the....jpg │ │ ├── Dogs _ Healthy Pets_ Healthy People _ CDC.jpg │ │ ├── Dogs caught coronavirus from their....jpg │ │ ├── First dog Major back at White House....jpg │ │ ├── Genes contribute to dog breeds_ iconic....jpg │ │ ├── Germany_ Dogs must be walked twice a....jpg │ │ ├── Great Dane - Wikipedia.jpg │ │ ├── Haunted Victorian Child_ Dog....jpg │ │ ├── Hong Kong dog causes panic – but here_s... (1).jpg │ │ ├── Hong Kong dog causes panic – but here_s....jpg │ │ ├── Hot dogs_ what soaring puppy thefts....jpg │ │ ├── How Many Dog Breeds Are There_ _ Hill_s Pet.jpg │ │ ├── How My Dog Knows When I_m Sick - The....jpg │ │ ├── How To Read Your Dog_s Body Language....png │ │ ├── How dogs contribute to your health and....jpg │ │ ├── How to make your dog feel comfortable....jpg │ │ ├── Important Things Every Dog Owner Should....jpg │ │ ├── Largest Dog Breeds – American Kennel Club.jpg │ │ ├── List of Dog Breeds _ Petfinder.jpg │ │ ├── List of dog breeds - Wikipedia.jpg │ │ ├── Maltese Dog Breed Information_ Pictures....jpg │ │ ├── Modern Dog magazine _ the best dog....jpg │ │ ├── Mood-Boosting Benefits of Pets....jpg │ │ ├── Most Expensive Dog Breeds For Pet....png │ │ ├── Most Popular Breeds – American Kennel Club.jpg │ │ ├── Most Popular Dog Breeds According....jpg │ │ ├── Most Popular Dog Names of 2020....jpg │ │ ├── Puppy Dog Pictures _ Download Free....jpg │ │ ├── Rescue turns dog with untreatable tumor....jpg │ │ ├── Rottweiler Dog Breed Information....jpg │ │ ├── Science_ Talking to Your Dog Means You....jpg │ │ ├── Service Dogs from Southeastern Guide Dogs.jpg │ │ ├── Soi Dog Foundation _ Ending The... (1).jpg │ │ ├── Soi Dog Foundation _ Ending The....jpg │ │ ├── Southeastern Guide Dogs - YouTube.jpg │ │ ├── Subaru Shows Love for Dogs Through the....jpg │ │ ├── The 20 Best Dog Breeds for Runners....jpg │ │ ├── The 25 Cutest Dog Breeds - Most....jpg │ │ ├── The Best Dogs of BBC Earth _ Top 5....jpg │ │ ├── The Black Dog Tavern Company _ Life off....jpg │ │ ├── The Cost of Owning a Dog.jpg │ │ ├── The History of Dogs as Pets - ABC News.jpg │ │ ├── The Importance of Walking Your Dog....jpg │ │ ├── The US Army is testing augmented....jpg │ │ ├── Those Puppy Dog Eyes You Can_t Resist....jpg │ │ ├── Top 10 Smartest Dog Breeds - Most....jpg │ │ ├── Trained dogs can smell coronavirus in....jpg │ │ ├── Welcoming Your Adopted Dog Into Your....jpg │ │ ├── What makes dogs so special and....jpg │ │ ├── Which Pop Culture Dog Is Best in Show....jpg │ │ ├── Why Grumpy Dogs Outperform Friendly....jpg │ │ ├── been calculating dog years wrong....jpg │ │ ├── best dog treats_ according to veterinarians.jpg │ │ ├── convert dog years to human years....jpg │ │ ├── dog existed at the end of the Ice Age_yythkg....jpg │ │ ├── real_ age_ you_ll need a calculator....jpg │ │ ├── scientists explain puppy dog eyes....jpg │ │ └── why dogs understand our body language....jpg └── tf_data_pipeline.ipynb ├── 45_prefatch └── prefetch_caching.ipynb ├── 46_BERT_intro └── bert_intro.ipynb ├── 47_BERT_text_classification ├── BERT_email_classification-Copy1.ipynb ├── BERT_email_classification-Copy2.ipynb ├── BERT_email_classification-handle-imbalance.ipynb ├── BERT_email_classification.ipynb └── spam.csv ├── 48_tf_serving ├── BERT_email_classification.ipynb ├── models.config.a ├── models.config.b ├── models.config.c ├── readme.md └── spam.csv ├── 49_quantization └── quantization.ipynb ├── 4_matrix_math ├── 4_matrix_math.ipynb ├── 4_matrix_math.md ├── 4_matrix_math_exercise_solution.ipynb ├── flowers.jpg ├── matrix_math.camproj ├── matrix_math_theory.trec └── revenue_usd.jpg ├── 5_loss ├── 5_loss_or_cost_function.ipynb └── loss_function_exercise_solution.ipynb ├── 6_gradient_descent ├── 6_gradient_descent.ipynb ├── insurance_data.csv └── nn.png ├── 7_nn_from_scratch ├── 7_neural_network_from_scratch.ipynb ├── insurance_data.csv └── nn.jpg ├── 8_sgd_vs_gd ├── gd_and_sgd.ipynb ├── gradient_descent.ipynb ├── gradient_descent.py ├── homeprices.csv ├── homeprices_banglore.csv ├── hp.jpg ├── mini_batch_gd.ipynb └── mini_batch_gd_exercise_solution.ipynb ├── 9_tensorboard └── digits_recognition_neural_network_tensorboard_demo.ipynb └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .idea/ 3 | **/.idea/ 4 | .ipynb_checkpoints/ 5 | **/.ipynb_checkpoints/ 6 | **/.cache/ 7 | .vscode 8 | -------------------------------------------------------------------------------- /10_gpu_benchmarking/DGX_performance/small_images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/10_gpu_benchmarking/DGX_performance/small_images.jpg -------------------------------------------------------------------------------- /10_gpu_benchmarking/Exercise/exercise_fashion_mnist_gpu_benchmarking.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

Exercise: GPU performance for fashion mnist dataset

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "This notebook is derived from a tensorflow tutorial here: https://www.tensorflow.org/tutorials/keras/classification\n", 15 | "So please refer to it before starting work on this exercise" 16 | ] 17 | }, 18 | { 19 | "cell_type": "markdown", 20 | "metadata": {}, 21 | "source": [ 22 | "You need to write code wherever you see `your code goes here` comment. You are going to do image classification for fashion mnist dataset and then you will benchmark the performance of GPU vs CPU for 1 hidden layer and then for 5 hidden layers. You will eventually fill out this table with your performance benchmark numbers\n", 23 | "\n", 24 | "\n", 25 | "| Hidden Layer | CPU | GPU |\n", 26 | "|:------|:------|:------|\n", 27 | "| 1 | ? | ? |\n", 28 | "| 5 | ? | ? |" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "# TensorFlow and tf.keras\n", 38 | "import tensorflow as tf\n", 39 | "from tensorflow import keras\n", 40 | "\n", 41 | "# Helper libraries\n", 42 | "import numpy as np\n", 43 | "import matplotlib.pyplot as plt\n", 44 | "\n", 45 | "print(tf.__version__)" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": null, 51 | "metadata": {}, 52 | "outputs": [], 53 | "source": [ 54 | "fashion_mnist = keras.datasets.fashion_mnist\n", 55 | "\n", 56 | "(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "metadata": {}, 63 | "outputs": [], 64 | "source": [ 65 | "class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',\n", 66 | " 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [ 75 | "train_images.shape" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": { 82 | "scrolled": true 83 | }, 84 | "outputs": [], 85 | "source": [ 86 | "plt.imshow(train_images[0])" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": {}, 93 | "outputs": [], 94 | "source": [ 95 | "train_labels[0]" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "class_names[train_labels[0]]" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "metadata": { 111 | "scrolled": false 112 | }, 113 | "outputs": [], 114 | "source": [ 115 | "plt.figure(figsize=(3,3))\n", 116 | "for i in range(5):\n", 117 | " plt.imshow(train_images[i])\n", 118 | " plt.xlabel(class_names[train_labels[i]])\n", 119 | " plt.show()" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": null, 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [ 128 | "train_images_scaled = train_images / 255.0\n", 129 | "test_images_scaled = test_images / 255.0" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [ 138 | "def get_model(hidden_layers=1):\n", 139 | " layers = []\n", 140 | " # Your code goes here-----------START\n", 141 | " # Create Flatten input layers\n", 142 | " # Create hidden layers that are equal to hidden_layers argument in this function\n", 143 | " # Create output \n", 144 | " # Your code goes here-----------END\n", 145 | " model = keras.Sequential(layers)\n", 146 | " \n", 147 | " model.compile(optimizer='adam',\n", 148 | " loss='sparse_categorical_crossentropy',\n", 149 | " metrics=['accuracy'])\n", 150 | " \n", 151 | " return model" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": null, 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [ 160 | "model = get_model(1)\n", 161 | "model.fit(train_images_scaled, train_labels, epochs=5)" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": null, 167 | "metadata": {}, 168 | "outputs": [], 169 | "source": [ 170 | "model.predict(test_images_scaled)[2]" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "metadata": {}, 177 | "outputs": [], 178 | "source": [ 179 | "test_labels[2]" 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": null, 185 | "metadata": {}, 186 | "outputs": [], 187 | "source": [ 188 | "tf.config.experimental.list_physical_devices() " 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "

5 Epochs performance comparison for 1 hidden layer

" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": null, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "%%timeit -n1 -r1\n", 205 | "with tf.device('/CPU:0'):\n", 206 | " # your code goes here" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": null, 212 | "metadata": { 213 | "scrolled": false 214 | }, 215 | "outputs": [], 216 | "source": [ 217 | "%%timeit -n1 -r1\n", 218 | "with tf.device('/GPU:0'):\n", 219 | " # your code goes here" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "metadata": {}, 225 | "source": [ 226 | "

5 Epocs performance comparison with 5 hidden layers

" 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": null, 232 | "metadata": {}, 233 | "outputs": [], 234 | "source": [ 235 | "%%timeit -n1 -r1\n", 236 | "with tf.device('/CPU:0'):\n", 237 | " # your code here" 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": null, 243 | "metadata": {}, 244 | "outputs": [], 245 | "source": [ 246 | "%%timeit -n1 -r1\n", 247 | "with tf.device('/GPU:0'):\n", 248 | " # your code here" 249 | ] 250 | }, 251 | { 252 | "cell_type": "markdown", 253 | "metadata": {}, 254 | "source": [ 255 | "[Click me to check solution for this exercise](https://github.com/codebasics/deep-learning-keras-tf-tutorial/blob/main/10_gpu_benchmarking/Exercise/exercise_solution.ipynb)" 256 | ] 257 | } 258 | ], 259 | "metadata": { 260 | "kernelspec": { 261 | "display_name": "Python 3", 262 | "language": "python", 263 | "name": "python3" 264 | }, 265 | "language_info": { 266 | "codemirror_mode": { 267 | "name": "ipython", 268 | "version": 3 269 | }, 270 | "file_extension": ".py", 271 | "mimetype": "text/x-python", 272 | "name": "python", 273 | "nbconvert_exporter": "python", 274 | "pygments_lexer": "ipython3", 275 | "version": "3.8.5" 276 | } 277 | }, 278 | "nbformat": 4, 279 | "nbformat_minor": 4 280 | } -------------------------------------------------------------------------------- /10_gpu_benchmarking/small_images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/10_gpu_benchmarking/small_images.jpg -------------------------------------------------------------------------------- /12_precision_recall/12_precision_recall.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 28, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from matplotlib import pyplot as plt\n", 10 | "from sklearn.metrics import confusion_matrix , classification_report\n", 11 | "import pandas as pd" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 29, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "# Source code credit for this function: https://gist.github.com/shaypal5/94c53d765083101efc0240d776a23823\n", 21 | "def print_confusion_matrix(confusion_matrix, class_names, figsize = (10,7), fontsize=14):\n", 22 | " \"\"\"Prints a confusion matrix, as returned by sklearn.metrics.confusion_matrix, as a heatmap.\n", 23 | " \n", 24 | " Arguments\n", 25 | " ---------\n", 26 | " confusion_matrix: numpy.ndarray\n", 27 | " The numpy.ndarray object returned from a call to sklearn.metrics.confusion_matrix. \n", 28 | " Similarly constructed ndarrays can also be used.\n", 29 | " class_names: list\n", 30 | " An ordered list of class names, in the order they index the given confusion matrix.\n", 31 | " figsize: tuple\n", 32 | " A 2-long tuple, the first value determining the horizontal size of the ouputted figure,\n", 33 | " the second determining the vertical size. Defaults to (10,7).\n", 34 | " fontsize: int\n", 35 | " Font size for axes labels. Defaults to 14.\n", 36 | " \n", 37 | " Returns\n", 38 | " -------\n", 39 | " matplotlib.figure.Figure\n", 40 | " The resulting confusion matrix figure\n", 41 | " \"\"\"\n", 42 | " df_cm = pd.DataFrame(\n", 43 | " confusion_matrix, index=class_names, columns=class_names, \n", 44 | " )\n", 45 | " fig = plt.figure(figsize=figsize)\n", 46 | " try:\n", 47 | " heatmap = sns.heatmap(df_cm, annot=True, fmt=\"d\")\n", 48 | " except ValueError:\n", 49 | " raise ValueError(\"Confusion matrix values must be integers.\")\n", 50 | " heatmap.yaxis.set_ticklabels(heatmap.yaxis.get_ticklabels(), rotation=0, ha='right', fontsize=fontsize)\n", 51 | " heatmap.xaxis.set_ticklabels(heatmap.xaxis.get_ticklabels(), rotation=45, ha='right', fontsize=fontsize)\n", 52 | " plt.ylabel('Truth')\n", 53 | " plt.xlabel('Prediction')" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 30, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [ 62 | "truth = [\"Dog\",\"Not a dog\",\"Dog\",\"Dog\", \"Dog\", \"Not a dog\", \"Not a dog\", \"Dog\", \"Dog\", \"Not a dog\"]\n", 63 | "prediction = [\"Dog\",\"Dog\", \"Dog\",\"Not a dog\",\"Dog\", \"Not a dog\", \"Dog\", \"Not a dog\", \"Dog\", \"Dog\"]" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 31, 69 | "metadata": { 70 | "scrolled": false 71 | }, 72 | "outputs": [ 73 | { 74 | "data": { 75 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAHeCAYAAAAmf1fGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAo8ElEQVR4nO3dd5xtdXnv8c+XA1gAwYJKAMVCooKNIEpiIcbkIhJJgjfijRoxegS9iWIvUYTYUDTqRT0eUQm2xILGghqjIKIiAtIEC2Kj2WgeinDOPPePtUa247TDmZm9zm8+b1/rNXuv9dtr/+bodp79PL+SqkKSJEnDtcm4OyBJkqTZGbBJkiQNnAGbJEnSwBmwSZIkDZwBmyRJ0sAZsEmSJA2cAZskSdICSrI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g2SZKkgTNgkyRJGjgDNkmSpIEzYJMkSRo4AzZJg5VkXZIzk5yb5CNJbr0B9zomyeP6x0cnuc8sbfdK8icjzw9K8uSb+96StKEM2CQN2XVV9YCq2hW4ATho9GKSFTfnplX1tKo6b5YmewG/DdiqalVVHXtz3kuSFoIBm6SNxVeAe/bZrxOSfBA4J8mKJG9I8s0kZyd5BnSbmic5Ksl5ST4D3HHyRklOTLJ7/3jvJGckOSvJF5PsRBcYHtJn9x6W5JVJnt+3f0CSU/r3+niS247c84gkpyb5XpKHLe0/j6SWbTruDkjSXPqNyh8NfK4/tQewa1X9MMlK4KqqelCSWwBfTfLfwAOBPwLuC9wJOA94z5T7bgu8C3h4f6/bVdXlSVYBa6rqyL7dn4+87Fjgn6rqy0kOBw4FntNf27Sq9kiyT3/+UQv8TyFpmTJgkzRkt0pyZv/4K8C76UqVp1bVD/vzfwncb3J8GrA1sDPwcOBDVbUOuCTJl6a5/0OAkybvVVWXz9aZJFsD21TVl/tT/w58ZKTJcf3P04Gd5vUbStI8GLBJGrLrquoBoyf6fcuvGT1Fl/H6/JR2+wBzbeWSebRZH7/pf67D/3+VtIAcwyZpY/d54OAkmwEk+cMkWwAnAQf0Y9y2A/5smtd+HXhEkrv1r71df/7XwFZTG1fVVcAVI+PTngR8eWo7SVpofgOUtLE7mq78eEa69NsvgL8GPg48EjgH+B7TBFZV9Yt+DNxxSTYBfg78BfAp4KNJ9gP+acrL/gFY1S8xciFw4CL8TpL0O9z8XZIkaeAsiUqSJA2cAZskSdLAGbBJkiQNnAGbJEnSwBmwSZIkDZwBmyRJ0sAZsEmSJA2cAZskSdLA/X9jlZJwHWKi2QAAAABJRU5ErkJggg==\n", 76 | "text/plain": [ 77 | "
" 78 | ] 79 | }, 80 | "metadata": { 81 | "needs_background": "light" 82 | }, 83 | "output_type": "display_data" 84 | } 85 | ], 86 | "source": [ 87 | "cm = confusion_matrix(truth,prediction)\n", 88 | "print_confusion_matrix(cm,[\"Dog\",\"Not a dog\"])" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 32, 94 | "metadata": {}, 95 | "outputs": [ 96 | { 97 | "name": "stdout", 98 | "output_type": "stream", 99 | "text": [ 100 | " precision recall f1-score support\n", 101 | "\n", 102 | " Dog 0.57 0.67 0.62 6\n", 103 | " Not a dog 0.33 0.25 0.29 4\n", 104 | "\n", 105 | " accuracy 0.50 10\n", 106 | " macro avg 0.45 0.46 0.45 10\n", 107 | "weighted avg 0.48 0.50 0.48 10\n", 108 | "\n" 109 | ] 110 | } 111 | ], 112 | "source": [ 113 | "print(classification_report(truth, prediction))" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "**f1 score for Dog class**" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": 33, 126 | "metadata": { 127 | "scrolled": true 128 | }, 129 | "outputs": [ 130 | { 131 | "data": { 132 | "text/plain": [ 133 | "0.6159677419354839" 134 | ] 135 | }, 136 | "execution_count": 33, 137 | "metadata": {}, 138 | "output_type": "execute_result" 139 | } 140 | ], 141 | "source": [ 142 | "2*(0.57*0.67/(0.57+0.67))" 143 | ] 144 | }, 145 | { 146 | "cell_type": "markdown", 147 | "metadata": {}, 148 | "source": [ 149 | "**f1 score for Not a dog class**" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": 36, 155 | "metadata": {}, 156 | "outputs": [ 157 | { 158 | "data": { 159 | "text/plain": [ 160 | "0.2844827586206896" 161 | ] 162 | }, 163 | "execution_count": 36, 164 | "metadata": {}, 165 | "output_type": "execute_result" 166 | } 167 | ], 168 | "source": [ 169 | "2*(0.33*0.25/(0.33+0.25))" 170 | ] 171 | } 172 | ], 173 | "metadata": { 174 | "kernelspec": { 175 | "display_name": "Python 3", 176 | "language": "python", 177 | "name": "python3" 178 | }, 179 | "language_info": { 180 | "codemirror_mode": { 181 | "name": "ipython", 182 | "version": 3 183 | }, 184 | "file_extension": ".py", 185 | "mimetype": "text/x-python", 186 | "name": "python", 187 | "nbconvert_exporter": "python", 188 | "pygments_lexer": "ipython3", 189 | "version": "3.8.5" 190 | } 191 | }, 192 | "nbformat": 4, 193 | "nbformat_minor": 4 194 | } 195 | -------------------------------------------------------------------------------- /14_imbalanced/handling_imbalanced_data_exercise.md: -------------------------------------------------------------------------------- 1 | #### Exercise: Handling imbalanced data in machine learning 2 | 3 | 1. Use [this notebook](https://github.com/codebasics/deep-learning-keras-tf-tutorial/blob/main/13_imbalanced/handling_imbalanced_data.ipynb) but handle imbalanced data using simple logistic regression from skelarn library. The original notebook using neural network but you need to use sklearn logistic regression or any other classification model and improve the f1-score of minority class using, 4 | 1. Undersampling 5 | 1. Oversampling: duplicate copy 6 | 1. OVersampling: SMOT 7 | 1. Ensemble 8 | 9 | [Solution](https://github.com/codebasics/deep-learning-keras-tf-tutorial/blob/main/14_imbalanced/handling_imbalanced_data_exercise_solution_telecom_churn.ipynb) 10 | 11 | 2. Take this dataset for bank customer churn prediction : https://www.kaggle.com/barelydedicated/bank-customer-churn-modeling 12 | 1. Build a deep learning model to predict churn rate at bank 13 | 1. Once model is built, print classification report and analyze precision, recall and f1-score 14 | 1. Improve f1 score in minority class using various techniques such as undersampling, oversampling, ensemble etc 15 | 16 | [Solution](https://github.com/codebasics/deep-learning-keras-tf-tutorial/blob/master/14_imbalanced/Handling%20Imbalanced%20Data%20In%20Customer%20Churn%20Using%20ANN/Bank%20Turnover%20Customer%20Churn%20Using%20ANN.ipynb) 17 | 18 | Thanks https://github.com/src-sohail for providing this solution. 19 | 20 | -------------------------------------------------------------------------------- /16_cnn_cifar10_small_image_classification/cnn_mnist_exercise_solution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

Handwritten digits classification using CNN

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "In this notebook we will classify handwritten digits using a simple neural network (ANN) first and than repeat same thing with convolutional neural network. We will see how accuracy improves clickly when you use convolutional neural network." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 27, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "import tensorflow as tf\n", 24 | "from tensorflow import keras\n", 25 | "from tensorflow.keras import datasets, layers, models\n", 26 | "import matplotlib.pyplot as plt\n", 27 | "%matplotlib inline\n", 28 | "import numpy as np" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 28, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "(X_train, y_train) , (X_test, y_test) = keras.datasets.mnist.load_data()" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 29, 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "data": { 47 | "text/plain": [ 48 | "(60000, 28, 28)" 49 | ] 50 | }, 51 | "execution_count": 29, 52 | "metadata": {}, 53 | "output_type": "execute_result" 54 | } 55 | ], 56 | "source": [ 57 | "X_train.shape" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 30, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "data": { 67 | "text/plain": [ 68 | "(10000, 28, 28)" 69 | ] 70 | }, 71 | "execution_count": 30, 72 | "metadata": {}, 73 | "output_type": "execute_result" 74 | } 75 | ], 76 | "source": [ 77 | "X_test.shape" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": 31, 83 | "metadata": {}, 84 | "outputs": [ 85 | { 86 | "data": { 87 | "text/plain": [ 88 | "(28, 28)" 89 | ] 90 | }, 91 | "execution_count": 31, 92 | "metadata": {}, 93 | "output_type": "execute_result" 94 | } 95 | ], 96 | "source": [ 97 | "X_train[0].shape" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 32, 103 | "metadata": {}, 104 | "outputs": [ 105 | { 106 | "data": { 107 | "text/plain": [ 108 | "" 109 | ] 110 | }, 111 | "execution_count": 32, 112 | "metadata": {}, 113 | "output_type": "execute_result" 114 | }, 115 | { 116 | "data": { 117 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQEAAAECCAYAAAD+eGJTAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAO9klEQVR4nO3df2xd9X3G8edpYpIFQhsvTZqyFNKQDlZYQ2fxQ0HAhMqyahKgibKoqlLWLawlbdkyCRZNg010yiagY4whhZERJKCFAiN/sLZRhIBq4JFkFEJToIWMhXgOwYIApSGxP/vDN5tH7e+1fX+cG3/eLyny9XmufT5c4Mm593zvuY4IAcjrA1UPAKBalACQHCUAJEcJAMlRAkBylACQXCUlYHu57edt/8T21VXMUGJ7l+1nbT9te2sHzLPB9l7bO0Zs67a92faLta9zOmy+a22/WnsMn7b92QrnW2j7Eds7bT9n++u17R3xGBbma8tj6HavE7A9TdILkj4jabekpyStiIgftXWQAtu7JPVExL6qZ5Ek2+dIelvSnRFxSm3b30oaiIh1tSKdExFXddB810p6OyKur2KmkWwvkLQgIrbbni1pm6SLJH1RHfAYFub7nNrwGFZxJHC6pJ9ExEsR8Z6kb0m6sII5jhgR8ZikgfdtvlDSxtrtjRr+j6YSY8zXMSKiLyK2126/JWmnpOPUIY9hYb62qKIEjpP0XyO+3602/gOPU0j6vu1ttldVPcwY5kdEnzT8H5GkeRXPM5rVtp+pPV2o7OnKSLZPkHSapF514GP4vvmkNjyGVZSAR9nWaWuXl0XEpyX9tqQraoe7mJhbJS2WtFRSn6QbKp1Gku1jJN0v6cqI2F/1PO83ynxteQyrKIHdkhaO+P5XJO2pYI4xRcSe2te9kh7U8FOYTtNfey55+Dnl3orn+X8ioj8iBiNiSNJtqvgxtN2l4f/B7oqIB2qbO+YxHG2+dj2GVZTAU5KW2F5k+yhJvydpUwV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 | }, 122 | "metadata": { 123 | "needs_background": "light" 124 | }, 125 | "output_type": "display_data" 126 | } 127 | ], 128 | "source": [ 129 | "plt.matshow(X_train[0])" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": 33, 135 | "metadata": {}, 136 | "outputs": [ 137 | { 138 | "data": { 139 | "text/plain": [ 140 | "5" 141 | ] 142 | }, 143 | "execution_count": 33, 144 | "metadata": {}, 145 | "output_type": "execute_result" 146 | } 147 | ], 148 | "source": [ 149 | "y_train[0]" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": 34, 155 | "metadata": {}, 156 | "outputs": [], 157 | "source": [ 158 | "X_train = X_train / 255\n", 159 | "X_test = X_test / 255" 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "

Using ANN for classification

" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 10, 172 | "metadata": { 173 | "scrolled": true 174 | }, 175 | "outputs": [ 176 | { 177 | "name": "stdout", 178 | "output_type": "stream", 179 | "text": [ 180 | "Epoch 1/10\n", 181 | "1875/1875 [==============================] - 2s 924us/step - loss: 0.2885 - accuracy: 0.9194\n", 182 | "Epoch 2/10\n", 183 | "1875/1875 [==============================] - 2s 920us/step - loss: 0.1363 - accuracy: 0.9603\n", 184 | "Epoch 3/10\n", 185 | "1875/1875 [==============================] - 2s 925us/step - loss: 0.0993 - accuracy: 0.9704\n", 186 | "Epoch 4/10\n", 187 | "1875/1875 [==============================] - 2s 929us/step - loss: 0.0765 - accuracy: 0.9771\n", 188 | "Epoch 5/10\n", 189 | "1875/1875 [==============================] - 2s 943us/step - loss: 0.0620 - accuracy: 0.9808\n", 190 | "Epoch 6/10\n", 191 | "1875/1875 [==============================] - 2s 938us/step - loss: 0.0509 - accuracy: 0.9843\n", 192 | "Epoch 7/10\n", 193 | "1875/1875 [==============================] - 2s 956us/step - loss: 0.0414 - accuracy: 0.9876\n", 194 | "Epoch 8/10\n", 195 | "1875/1875 [==============================] - 2s 971us/step - loss: 0.0363 - accuracy: 0.9887\n", 196 | "Epoch 9/10\n", 197 | "1875/1875 [==============================] - 2s 961us/step - loss: 0.0301 - accuracy: 0.9905\n", 198 | "Epoch 10/10\n", 199 | "1875/1875 [==============================] - 2s 963us/step - loss: 0.0237 - accuracy: 0.9926\n" 200 | ] 201 | }, 202 | { 203 | "data": { 204 | "text/plain": [ 205 | "" 206 | ] 207 | }, 208 | "execution_count": 10, 209 | "metadata": {}, 210 | "output_type": "execute_result" 211 | } 212 | ], 213 | "source": [ 214 | "model = keras.Sequential([\n", 215 | " keras.layers.Flatten(input_shape=(28, 28)),\n", 216 | " keras.layers.Dense(100, activation='relu'),\n", 217 | " keras.layers.Dense(10, activation='sigmoid')\n", 218 | "])\n", 219 | "\n", 220 | "model.compile(optimizer='adam',\n", 221 | " loss='sparse_categorical_crossentropy',\n", 222 | " metrics=['accuracy'])\n", 223 | "\n", 224 | "model.fit(X_train, y_train, epochs=10)" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": 11, 230 | "metadata": {}, 231 | "outputs": [ 232 | { 233 | "name": "stdout", 234 | "output_type": "stream", 235 | "text": [ 236 | "313/313 [==============================] - 0s 988us/step - loss: 0.0831 - accuracy: 0.9780\n" 237 | ] 238 | }, 239 | { 240 | "data": { 241 | "text/plain": [ 242 | "[0.0830635279417038, 0.9779999852180481]" 243 | ] 244 | }, 245 | "execution_count": 11, 246 | "metadata": {}, 247 | "output_type": "execute_result" 248 | } 249 | ], 250 | "source": [ 251 | "model.evaluate(X_test,y_test)" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 35, 257 | "metadata": {}, 258 | "outputs": [ 259 | { 260 | "data": { 261 | "text/plain": [ 262 | "(60000, 28, 28, 1)" 263 | ] 264 | }, 265 | "execution_count": 35, 266 | "metadata": {}, 267 | "output_type": "execute_result" 268 | } 269 | ], 270 | "source": [ 271 | "X_train = X_train.reshape(-1,28,28,1)\n", 272 | "X_train.shape" 273 | ] 274 | }, 275 | { 276 | "cell_type": "code", 277 | "execution_count": 40, 278 | "metadata": { 279 | "scrolled": true 280 | }, 281 | "outputs": [ 282 | { 283 | "data": { 284 | "text/plain": [ 285 | "(10000, 28, 28, 1)" 286 | ] 287 | }, 288 | "execution_count": 40, 289 | "metadata": {}, 290 | "output_type": "execute_result" 291 | } 292 | ], 293 | "source": [ 294 | "X_test = X_test.reshape(-1,28,28,1)\n", 295 | "X_test.shape" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "

Using CNN for classification

" 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "execution_count": 59, 308 | "metadata": {}, 309 | "outputs": [], 310 | "source": [ 311 | "model = keras.Sequential([\n", 312 | " \n", 313 | " layers.Conv2D(30, (3,3), activation='relu', input_shape=(28, 28, 1)),\n", 314 | " layers.MaxPooling2D((2,2)),\n", 315 | " \n", 316 | " layers.Flatten(),\n", 317 | " layers.Dense(100, activation='relu'),\n", 318 | " keras.layers.Dense(10, activation='sigmoid')\n", 319 | "])" 320 | ] 321 | }, 322 | { 323 | "cell_type": "code", 324 | "execution_count": 60, 325 | "metadata": { 326 | "scrolled": true 327 | }, 328 | "outputs": [ 329 | { 330 | "name": "stdout", 331 | "output_type": "stream", 332 | "text": [ 333 | "Epoch 1/5\n", 334 | "1875/1875 [==============================] - 2s 1ms/step - loss: 0.1739 - accuracy: 0.9488\n", 335 | "Epoch 2/5\n", 336 | "1875/1875 [==============================] - 2s 1ms/step - loss: 0.0610 - accuracy: 0.9814\n", 337 | "Epoch 3/5\n", 338 | "1875/1875 [==============================] - 2s 1ms/step - loss: 0.0398 - accuracy: 0.9872\n", 339 | "Epoch 4/5\n", 340 | "1875/1875 [==============================] - 2s 1ms/step - loss: 0.0291 - accuracy: 0.9909\n", 341 | "Epoch 5/5\n", 342 | "1875/1875 [==============================] - 2s 1ms/step - loss: 0.0207 - accuracy: 0.9934\n" 343 | ] 344 | }, 345 | { 346 | "data": { 347 | "text/plain": [ 348 | "" 349 | ] 350 | }, 351 | "execution_count": 60, 352 | "metadata": {}, 353 | "output_type": "execute_result" 354 | } 355 | ], 356 | "source": [ 357 | "model.compile(optimizer='adam',\n", 358 | " loss='sparse_categorical_crossentropy',\n", 359 | " metrics=['accuracy'])\n", 360 | "\n", 361 | "model.fit(X_train, y_train, epochs=5)" 362 | ] 363 | }, 364 | { 365 | "cell_type": "code", 366 | "execution_count": 61, 367 | "metadata": {}, 368 | "outputs": [ 369 | { 370 | "data": { 371 | "text/plain": [ 372 | "array([5, 0, 4, 1, 9], dtype=uint8)" 373 | ] 374 | }, 375 | "execution_count": 61, 376 | "metadata": {}, 377 | "output_type": "execute_result" 378 | } 379 | ], 380 | "source": [ 381 | "y_train[:5]" 382 | ] 383 | }, 384 | { 385 | "cell_type": "code", 386 | "execution_count": 56, 387 | "metadata": {}, 388 | "outputs": [ 389 | { 390 | "name": "stdout", 391 | "output_type": "stream", 392 | "text": [ 393 | "313/313 [==============================] - 0s 1ms/step - loss: 0.0541 - accuracy: 0.9843\n" 394 | ] 395 | }, 396 | { 397 | "data": { 398 | "text/plain": [ 399 | "[0.05414153262972832, 0.9843000173568726]" 400 | ] 401 | }, 402 | "execution_count": 56, 403 | "metadata": {}, 404 | "output_type": "execute_result" 405 | } 406 | ], 407 | "source": [ 408 | "model.evaluate(X_test,y_test)" 409 | ] 410 | } 411 | ], 412 | "metadata": { 413 | "kernelspec": { 414 | "display_name": "Python 3", 415 | "language": "python", 416 | "name": "python3" 417 | }, 418 | "language_info": { 419 | "codemirror_mode": { 420 | "name": "ipython", 421 | "version": 3 422 | }, 423 | "file_extension": ".py", 424 | "mimetype": "text/x-python", 425 | "name": "python", 426 | "nbconvert_exporter": "python", 427 | "pygments_lexer": "ipython3", 428 | "version": "3.8.5" 429 | } 430 | }, 431 | "nbformat": 4, 432 | "nbformat_minor": 4 433 | } 434 | -------------------------------------------------------------------------------- /16_cnn_cifar10_small_image_classification/digits_nn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/16_cnn_cifar10_small_image_classification/digits_nn.jpg -------------------------------------------------------------------------------- /16_cnn_cifar10_small_image_classification/small_images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/16_cnn_cifar10_small_image_classification/small_images.jpg -------------------------------------------------------------------------------- /17_data_augmentation/daisy2.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/17_data_augmentation/daisy2.JPG -------------------------------------------------------------------------------- /18_transfer_learning/ImageNetLabels.txt: -------------------------------------------------------------------------------- 1 | background 2 | tench 3 | goldfish 4 | great white shark 5 | tiger shark 6 | hammerhead 7 | electric ray 8 | stingray 9 | cock 10 | hen 11 | ostrich 12 | brambling 13 | goldfinch 14 | house finch 15 | junco 16 | indigo bunting 17 | robin 18 | bulbul 19 | jay 20 | magpie 21 | chickadee 22 | water ouzel 23 | kite 24 | bald eagle 25 | vulture 26 | great grey owl 27 | European fire salamander 28 | common newt 29 | eft 30 | spotted salamander 31 | axolotl 32 | bullfrog 33 | tree frog 34 | tailed frog 35 | loggerhead 36 | leatherback turtle 37 | mud turtle 38 | terrapin 39 | box turtle 40 | banded gecko 41 | common iguana 42 | American chameleon 43 | whiptail 44 | agama 45 | frilled lizard 46 | alligator lizard 47 | Gila monster 48 | green lizard 49 | African chameleon 50 | Komodo dragon 51 | African crocodile 52 | American alligator 53 | triceratops 54 | thunder snake 55 | ringneck snake 56 | hognose snake 57 | green snake 58 | king snake 59 | garter snake 60 | water snake 61 | vine snake 62 | night snake 63 | boa constrictor 64 | rock python 65 | Indian cobra 66 | green mamba 67 | sea snake 68 | horned viper 69 | diamondback 70 | sidewinder 71 | trilobite 72 | harvestman 73 | scorpion 74 | black and gold garden spider 75 | barn spider 76 | garden spider 77 | black widow 78 | tarantula 79 | wolf spider 80 | tick 81 | centipede 82 | black grouse 83 | ptarmigan 84 | ruffed grouse 85 | prairie chicken 86 | peacock 87 | quail 88 | partridge 89 | African grey 90 | macaw 91 | sulphur-crested cockatoo 92 | lorikeet 93 | coucal 94 | bee eater 95 | hornbill 96 | hummingbird 97 | jacamar 98 | toucan 99 | drake 100 | red-breasted merganser 101 | goose 102 | black swan 103 | tusker 104 | echidna 105 | platypus 106 | wallaby 107 | koala 108 | wombat 109 | jellyfish 110 | sea anemone 111 | brain coral 112 | flatworm 113 | nematode 114 | conch 115 | snail 116 | slug 117 | sea slug 118 | chiton 119 | chambered nautilus 120 | Dungeness crab 121 | rock crab 122 | fiddler crab 123 | king crab 124 | American lobster 125 | spiny lobster 126 | crayfish 127 | hermit crab 128 | isopod 129 | white stork 130 | black stork 131 | spoonbill 132 | flamingo 133 | little blue heron 134 | American egret 135 | bittern 136 | crane 137 | limpkin 138 | European gallinule 139 | American coot 140 | bustard 141 | ruddy turnstone 142 | red-backed sandpiper 143 | redshank 144 | dowitcher 145 | oystercatcher 146 | pelican 147 | king penguin 148 | albatross 149 | grey whale 150 | killer whale 151 | dugong 152 | sea lion 153 | Chihuahua 154 | Japanese spaniel 155 | Maltese dog 156 | Pekinese 157 | Shih-Tzu 158 | Blenheim spaniel 159 | papillon 160 | toy terrier 161 | Rhodesian ridgeback 162 | Afghan hound 163 | basset 164 | beagle 165 | bloodhound 166 | bluetick 167 | black-and-tan coonhound 168 | Walker hound 169 | English foxhound 170 | redbone 171 | borzoi 172 | Irish wolfhound 173 | Italian greyhound 174 | whippet 175 | Ibizan hound 176 | Norwegian elkhound 177 | otterhound 178 | Saluki 179 | Scottish deerhound 180 | Weimaraner 181 | Staffordshire bullterrier 182 | American Staffordshire terrier 183 | Bedlington terrier 184 | Border terrier 185 | Kerry blue terrier 186 | Irish terrier 187 | Norfolk terrier 188 | Norwich terrier 189 | Yorkshire terrier 190 | wire-haired fox terrier 191 | Lakeland terrier 192 | Sealyham terrier 193 | Airedale 194 | cairn 195 | Australian terrier 196 | Dandie Dinmont 197 | Boston bull 198 | miniature schnauzer 199 | giant schnauzer 200 | standard schnauzer 201 | Scotch terrier 202 | Tibetan terrier 203 | silky terrier 204 | soft-coated wheaten terrier 205 | West Highland white terrier 206 | Lhasa 207 | flat-coated retriever 208 | curly-coated retriever 209 | golden retriever 210 | Labrador retriever 211 | Chesapeake Bay retriever 212 | German short-haired pointer 213 | vizsla 214 | English setter 215 | Irish setter 216 | Gordon setter 217 | Brittany spaniel 218 | clumber 219 | English springer 220 | Welsh springer spaniel 221 | cocker spaniel 222 | Sussex spaniel 223 | Irish water spaniel 224 | kuvasz 225 | schipperke 226 | groenendael 227 | malinois 228 | briard 229 | kelpie 230 | komondor 231 | Old English sheepdog 232 | Shetland sheepdog 233 | collie 234 | Border collie 235 | Bouvier des Flandres 236 | Rottweiler 237 | German shepherd 238 | Doberman 239 | miniature pinscher 240 | Greater Swiss Mountain dog 241 | Bernese mountain dog 242 | Appenzeller 243 | EntleBucher 244 | boxer 245 | bull mastiff 246 | Tibetan mastiff 247 | French bulldog 248 | Great Dane 249 | Saint Bernard 250 | Eskimo dog 251 | malamute 252 | Siberian husky 253 | dalmatian 254 | affenpinscher 255 | basenji 256 | pug 257 | Leonberg 258 | Newfoundland 259 | Great Pyrenees 260 | Samoyed 261 | Pomeranian 262 | chow 263 | keeshond 264 | Brabancon griffon 265 | Pembroke 266 | Cardigan 267 | toy poodle 268 | miniature poodle 269 | standard poodle 270 | Mexican hairless 271 | timber wolf 272 | white wolf 273 | red wolf 274 | coyote 275 | dingo 276 | dhole 277 | African hunting dog 278 | hyena 279 | red fox 280 | kit fox 281 | Arctic fox 282 | grey fox 283 | tabby 284 | tiger cat 285 | Persian cat 286 | Siamese cat 287 | Egyptian cat 288 | cougar 289 | lynx 290 | leopard 291 | snow leopard 292 | jaguar 293 | lion 294 | tiger 295 | cheetah 296 | brown bear 297 | American black bear 298 | ice bear 299 | sloth bear 300 | mongoose 301 | meerkat 302 | tiger beetle 303 | ladybug 304 | ground beetle 305 | long-horned beetle 306 | leaf beetle 307 | dung beetle 308 | rhinoceros beetle 309 | weevil 310 | fly 311 | bee 312 | ant 313 | grasshopper 314 | cricket 315 | walking stick 316 | cockroach 317 | mantis 318 | cicada 319 | leafhopper 320 | lacewing 321 | dragonfly 322 | damselfly 323 | admiral 324 | ringlet 325 | monarch 326 | cabbage butterfly 327 | sulphur butterfly 328 | lycaenid 329 | starfish 330 | sea urchin 331 | sea cucumber 332 | wood rabbit 333 | hare 334 | Angora 335 | hamster 336 | porcupine 337 | fox squirrel 338 | marmot 339 | beaver 340 | guinea pig 341 | sorrel 342 | zebra 343 | hog 344 | wild boar 345 | warthog 346 | hippopotamus 347 | ox 348 | water buffalo 349 | bison 350 | ram 351 | bighorn 352 | ibex 353 | hartebeest 354 | impala 355 | gazelle 356 | Arabian camel 357 | llama 358 | weasel 359 | mink 360 | polecat 361 | black-footed ferret 362 | otter 363 | skunk 364 | badger 365 | armadillo 366 | three-toed sloth 367 | orangutan 368 | gorilla 369 | chimpanzee 370 | gibbon 371 | siamang 372 | guenon 373 | patas 374 | baboon 375 | macaque 376 | langur 377 | colobus 378 | proboscis monkey 379 | marmoset 380 | capuchin 381 | howler monkey 382 | titi 383 | spider monkey 384 | squirrel monkey 385 | Madagascar cat 386 | indri 387 | Indian elephant 388 | African elephant 389 | lesser panda 390 | giant panda 391 | barracouta 392 | eel 393 | coho 394 | rock beauty 395 | anemone fish 396 | sturgeon 397 | gar 398 | lionfish 399 | puffer 400 | abacus 401 | abaya 402 | academic gown 403 | accordion 404 | acoustic guitar 405 | aircraft carrier 406 | airliner 407 | airship 408 | altar 409 | ambulance 410 | amphibian 411 | analog clock 412 | apiary 413 | apron 414 | ashcan 415 | assault rifle 416 | backpack 417 | bakery 418 | balance beam 419 | balloon 420 | ballpoint 421 | Band Aid 422 | banjo 423 | bannister 424 | barbell 425 | barber chair 426 | barbershop 427 | barn 428 | barometer 429 | barrel 430 | barrow 431 | baseball 432 | basketball 433 | bassinet 434 | bassoon 435 | bathing cap 436 | bath towel 437 | bathtub 438 | beach wagon 439 | beacon 440 | beaker 441 | bearskin 442 | beer bottle 443 | beer glass 444 | bell cote 445 | bib 446 | bicycle-built-for-two 447 | bikini 448 | binder 449 | binoculars 450 | birdhouse 451 | boathouse 452 | bobsled 453 | bolo tie 454 | bonnet 455 | bookcase 456 | bookshop 457 | bottlecap 458 | bow 459 | bow tie 460 | brass 461 | brassiere 462 | breakwater 463 | breastplate 464 | broom 465 | bucket 466 | buckle 467 | bulletproof vest 468 | bullet train 469 | butcher shop 470 | cab 471 | caldron 472 | candle 473 | cannon 474 | canoe 475 | can opener 476 | cardigan 477 | car mirror 478 | carousel 479 | carpenter's kit 480 | carton 481 | car wheel 482 | cash machine 483 | cassette 484 | cassette player 485 | castle 486 | catamaran 487 | CD player 488 | cello 489 | cellular telephone 490 | chain 491 | chainlink fence 492 | chain mail 493 | chain saw 494 | chest 495 | chiffonier 496 | chime 497 | china cabinet 498 | Christmas stocking 499 | church 500 | cinema 501 | cleaver 502 | cliff dwelling 503 | cloak 504 | clog 505 | cocktail shaker 506 | coffee mug 507 | coffeepot 508 | coil 509 | combination lock 510 | computer keyboard 511 | confectionery 512 | container ship 513 | convertible 514 | corkscrew 515 | cornet 516 | cowboy boot 517 | cowboy hat 518 | cradle 519 | crane 520 | crash helmet 521 | crate 522 | crib 523 | Crock Pot 524 | croquet ball 525 | crutch 526 | cuirass 527 | dam 528 | desk 529 | desktop computer 530 | dial telephone 531 | diaper 532 | digital clock 533 | digital watch 534 | dining table 535 | dishrag 536 | dishwasher 537 | disk brake 538 | dock 539 | dogsled 540 | dome 541 | doormat 542 | drilling platform 543 | drum 544 | drumstick 545 | dumbbell 546 | Dutch oven 547 | electric fan 548 | electric guitar 549 | electric locomotive 550 | entertainment center 551 | envelope 552 | espresso maker 553 | face powder 554 | feather boa 555 | file 556 | fireboat 557 | fire engine 558 | fire screen 559 | flagpole 560 | flute 561 | folding chair 562 | football helmet 563 | forklift 564 | fountain 565 | fountain pen 566 | four-poster 567 | freight car 568 | French horn 569 | frying pan 570 | fur coat 571 | garbage truck 572 | gasmask 573 | gas pump 574 | goblet 575 | go-kart 576 | golf ball 577 | golfcart 578 | gondola 579 | gong 580 | gown 581 | grand piano 582 | greenhouse 583 | grille 584 | grocery store 585 | guillotine 586 | hair slide 587 | hair spray 588 | half track 589 | hammer 590 | hamper 591 | hand blower 592 | hand-held computer 593 | handkerchief 594 | hard disc 595 | harmonica 596 | harp 597 | harvester 598 | hatchet 599 | holster 600 | home theater 601 | honeycomb 602 | hook 603 | hoopskirt 604 | horizontal bar 605 | horse cart 606 | hourglass 607 | iPod 608 | iron 609 | jack-o'-lantern 610 | jean 611 | jeep 612 | jersey 613 | jigsaw puzzle 614 | jinrikisha 615 | joystick 616 | kimono 617 | knee pad 618 | knot 619 | lab coat 620 | ladle 621 | lampshade 622 | laptop 623 | lawn mower 624 | lens cap 625 | letter opener 626 | library 627 | lifeboat 628 | lighter 629 | limousine 630 | liner 631 | lipstick 632 | Loafer 633 | lotion 634 | loudspeaker 635 | loupe 636 | lumbermill 637 | magnetic compass 638 | mailbag 639 | mailbox 640 | maillot 641 | maillot 642 | manhole cover 643 | maraca 644 | marimba 645 | mask 646 | matchstick 647 | maypole 648 | maze 649 | measuring cup 650 | medicine chest 651 | megalith 652 | microphone 653 | microwave 654 | military uniform 655 | milk can 656 | minibus 657 | miniskirt 658 | minivan 659 | missile 660 | mitten 661 | mixing bowl 662 | mobile home 663 | Model T 664 | modem 665 | monastery 666 | monitor 667 | moped 668 | mortar 669 | mortarboard 670 | mosque 671 | mosquito net 672 | motor scooter 673 | mountain bike 674 | mountain tent 675 | mouse 676 | mousetrap 677 | moving van 678 | muzzle 679 | nail 680 | neck brace 681 | necklace 682 | nipple 683 | notebook 684 | obelisk 685 | oboe 686 | ocarina 687 | odometer 688 | oil filter 689 | organ 690 | oscilloscope 691 | overskirt 692 | oxcart 693 | oxygen mask 694 | packet 695 | paddle 696 | paddlewheel 697 | padlock 698 | paintbrush 699 | pajama 700 | palace 701 | panpipe 702 | paper towel 703 | parachute 704 | parallel bars 705 | park bench 706 | parking meter 707 | passenger car 708 | patio 709 | pay-phone 710 | pedestal 711 | pencil box 712 | pencil sharpener 713 | perfume 714 | Petri dish 715 | photocopier 716 | pick 717 | pickelhaube 718 | picket fence 719 | pickup 720 | pier 721 | piggy bank 722 | pill bottle 723 | pillow 724 | ping-pong ball 725 | pinwheel 726 | pirate 727 | pitcher 728 | plane 729 | planetarium 730 | plastic bag 731 | plate rack 732 | plow 733 | plunger 734 | Polaroid camera 735 | pole 736 | police van 737 | poncho 738 | pool table 739 | pop bottle 740 | pot 741 | potter's wheel 742 | power drill 743 | prayer rug 744 | printer 745 | prison 746 | projectile 747 | projector 748 | puck 749 | punching bag 750 | purse 751 | quill 752 | quilt 753 | racer 754 | racket 755 | radiator 756 | radio 757 | radio telescope 758 | rain barrel 759 | recreational vehicle 760 | reel 761 | reflex camera 762 | refrigerator 763 | remote control 764 | restaurant 765 | revolver 766 | rifle 767 | rocking chair 768 | rotisserie 769 | rubber eraser 770 | rugby ball 771 | rule 772 | running shoe 773 | safe 774 | safety pin 775 | saltshaker 776 | sandal 777 | sarong 778 | sax 779 | scabbard 780 | scale 781 | school bus 782 | schooner 783 | scoreboard 784 | screen 785 | screw 786 | screwdriver 787 | seat belt 788 | sewing machine 789 | shield 790 | shoe shop 791 | shoji 792 | shopping basket 793 | shopping cart 794 | shovel 795 | shower cap 796 | shower curtain 797 | ski 798 | ski mask 799 | sleeping bag 800 | slide rule 801 | sliding door 802 | slot 803 | snorkel 804 | snowmobile 805 | snowplow 806 | soap dispenser 807 | soccer ball 808 | sock 809 | solar dish 810 | sombrero 811 | soup bowl 812 | space bar 813 | space heater 814 | space shuttle 815 | spatula 816 | speedboat 817 | spider web 818 | spindle 819 | sports car 820 | spotlight 821 | stage 822 | steam locomotive 823 | steel arch bridge 824 | steel drum 825 | stethoscope 826 | stole 827 | stone wall 828 | stopwatch 829 | stove 830 | strainer 831 | streetcar 832 | stretcher 833 | studio couch 834 | stupa 835 | submarine 836 | suit 837 | sundial 838 | sunglass 839 | sunglasses 840 | sunscreen 841 | suspension bridge 842 | swab 843 | sweatshirt 844 | swimming trunks 845 | swing 846 | switch 847 | syringe 848 | table lamp 849 | tank 850 | tape player 851 | teapot 852 | teddy 853 | television 854 | tennis ball 855 | thatch 856 | theater curtain 857 | thimble 858 | thresher 859 | throne 860 | tile roof 861 | toaster 862 | tobacco shop 863 | toilet seat 864 | torch 865 | totem pole 866 | tow truck 867 | toyshop 868 | tractor 869 | trailer truck 870 | tray 871 | trench coat 872 | tricycle 873 | trimaran 874 | tripod 875 | triumphal arch 876 | trolleybus 877 | trombone 878 | tub 879 | turnstile 880 | typewriter keyboard 881 | umbrella 882 | unicycle 883 | upright 884 | vacuum 885 | vase 886 | vault 887 | velvet 888 | vending machine 889 | vestment 890 | viaduct 891 | violin 892 | volleyball 893 | waffle iron 894 | wall clock 895 | wallet 896 | wardrobe 897 | warplane 898 | washbasin 899 | washer 900 | water bottle 901 | water jug 902 | water tower 903 | whiskey jug 904 | whistle 905 | wig 906 | window screen 907 | window shade 908 | Windsor tie 909 | wine bottle 910 | wing 911 | wok 912 | wooden spoon 913 | wool 914 | worm fence 915 | wreck 916 | yawl 917 | yurt 918 | web site 919 | comic book 920 | crossword puzzle 921 | street sign 922 | traffic light 923 | book jacket 924 | menu 925 | plate 926 | guacamole 927 | consomme 928 | hot pot 929 | trifle 930 | ice cream 931 | ice lolly 932 | French loaf 933 | bagel 934 | pretzel 935 | cheeseburger 936 | hotdog 937 | mashed potato 938 | head cabbage 939 | broccoli 940 | cauliflower 941 | zucchini 942 | spaghetti squash 943 | acorn squash 944 | butternut squash 945 | cucumber 946 | artichoke 947 | bell pepper 948 | cardoon 949 | mushroom 950 | Granny Smith 951 | strawberry 952 | orange 953 | lemon 954 | fig 955 | pineapple 956 | banana 957 | jackfruit 958 | custard apple 959 | pomegranate 960 | hay 961 | carbonara 962 | chocolate sauce 963 | dough 964 | meat loaf 965 | pizza 966 | potpie 967 | burrito 968 | red wine 969 | espresso 970 | cup 971 | eggnog 972 | alp 973 | bubble 974 | cliff 975 | coral reef 976 | geyser 977 | lakeside 978 | promontory 979 | sandbar 980 | seashore 981 | valley 982 | volcano 983 | ballplayer 984 | groom 985 | scuba diver 986 | rapeseed 987 | daisy 988 | yellow lady's slipper 989 | corn 990 | acorn 991 | hip 992 | buckeye 993 | coral fungus 994 | agaric 995 | gyromitra 996 | stinkhorn 997 | earthstar 998 | hen-of-the-woods 999 | bolete 1000 | ear 1001 | toilet tissue 1002 | -------------------------------------------------------------------------------- /18_transfer_learning/goldfish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/18_transfer_learning/goldfish.jpg -------------------------------------------------------------------------------- /1_digits_recognition/digits_nn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/1_digits_recognition/digits_nn.jpg -------------------------------------------------------------------------------- /1_keras_fashion_mnist_neural_net/Exercise/1_keras_sequential_exercise.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stderr", 10 | "output_type": "stream", 11 | "text": [ 12 | "Using TensorFlow backend.\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "import keras\n", 18 | "import numpy as np\n", 19 | "import matplotlib.pyplot as plt\n", 20 | "%matplotlib inline" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 23, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "digits = keras.datasets.mnist\n", 30 | "(X_train, y_train), (X_test, y_test) = digits.load_data()" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 29, 36 | "metadata": { 37 | "collapsed": true 38 | }, 39 | "outputs": [], 40 | "source": [ 41 | "X_train = X_train/255\n", 42 | "X_test = X_test/255" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 30, 48 | "metadata": { 49 | "scrolled": true 50 | }, 51 | "outputs": [ 52 | { 53 | "data": { 54 | "text/plain": [ 55 | "" 56 | ] 57 | }, 58 | "execution_count": 30, 59 | "metadata": {}, 60 | "output_type": "execute_result" 61 | }, 62 | { 63 | "data": { 64 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQQAAAECCAYAAAAYUakXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADzJJREFUeJzt3X2QVfV9x/HPB7KCIDhQIyFWS4kSSm0DdaOxMcHEiYN2\npupMQ8p0DLV2cCYJxWjbOE5ndNJpx2Z8yIMPKUYiNkrGGZ+YDjVFytSYKHFBKggaLYEKrlDBFh+R\nZb/9Y4+/bA37O7t7H85hfb9mmL17Ppc9X4/48Zx7f5zriBAASNKoqgcAUB8UAoCEQgCQUAgAEgoB\nQEIhAEgqKQTb82w/Z/sF21dVMUOO7e22N9neaLurBvMss73H9uZ+2ybbXm37+eLrpJrNd63tXcUx\n3Gj7/ArnO9H2WttbbD9je0mxvRbHMDNf24+h270OwfZoST+X9DlJOyU9KWlBRGxp6yAZtrdL6oyI\nV6qeRZJsf1rS65LuiohTi23fkLQvIq4rSnVSRHytRvNdK+n1iLi+ipn6sz1V0tSI2GB7gqT1ki6U\n9KeqwTHMzDdfbT6GVZwhnC7phYjYFhHvSPqhpAsqmOOIERGPStr3ns0XSFpePF6uvj9AlRhgvtqI\niO6I2FA8fk3SVkknqCbHMDNf21VRCCdIerHf9ztV0T98Rkh6xPZ624uqHmY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fpMsjYr+k\n2yRNlzRbfWcQNwzw+xbZ7rLddVAHmjAygFYZVCHY7lBfGdwdEfdLUkTsjohDEdEr6XZJpx/u90bE\n0ojojIjODo1p1twAWmAw7zJY0h2StkbEjf22T+33tIskbW7+eADaaTDvMnxS0sWSNtneWGy7WtIC\n27MlhaTtki5ryYQA2mYw7zI8Julwf496VfPHAVAlVioCSCgEAAmFACChEAAkFAKAhEIAkFAIABIK\nAUBCIQBIKAQACYUAIKEQACQUAoCEQgCQUAgAEkdE+3Zm/7ekHf02HSfplbYNMHTM15g6z1fn2aTm\nz/cbEfHBsie1tRB+Zed2V0R0VjZACeZrTJ3nq/NsUnXzcckAIKEQACRVF8LSivdfhvkaU+f56jyb\nVNF8lb6GAKBeqj5DAFAjFAKAhEIAkFAIABIKAUDyf/zrMqJGa9wyAAAAAElFTkSuQmCC\n", 65 | "text/plain": [ 66 | "" 67 | ] 68 | }, 69 | "metadata": {}, 70 | "output_type": "display_data" 71 | } 72 | ], 73 | "source": [ 74 | "plt.matshow(X_train[1])" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 31, 80 | "metadata": { 81 | "scrolled": true 82 | }, 83 | "outputs": [ 84 | { 85 | "data": { 86 | "text/plain": [ 87 | "0" 88 | ] 89 | }, 90 | "execution_count": 31, 91 | "metadata": {}, 92 | "output_type": "execute_result" 93 | } 94 | ], 95 | "source": [ 96 | "y_train[1]" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 32, 102 | "metadata": {}, 103 | "outputs": [], 104 | "source": [ 105 | "model = keras.models.Sequential()\n", 106 | "model.add(keras.layers.Flatten(input_shape=[28, 28]))\n", 107 | "model.add(keras.layers.Dense(20, activation=\"relu\"))\n", 108 | "model.add(keras.layers.Dense(10, activation=\"softmax\"))" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 19, 114 | "metadata": { 115 | "scrolled": true 116 | }, 117 | "outputs": [ 118 | { 119 | "name": "stdout", 120 | "output_type": "stream", 121 | "text": [ 122 | "_________________________________________________________________\n", 123 | "Layer (type) Output Shape Param # \n", 124 | "=================================================================\n", 125 | "flatten_1 (Flatten) (None, 784) 0 \n", 126 | "_________________________________________________________________\n", 127 | "dense_1 (Dense) (None, 20) 15700 \n", 128 | "_________________________________________________________________\n", 129 | "dense_2 (Dense) (None, 10) 210 \n", 130 | "=================================================================\n", 131 | "Total params: 15,910\n", 132 | "Trainable params: 15,910\n", 133 | "Non-trainable params: 0\n", 134 | "_________________________________________________________________\n" 135 | ] 136 | } 137 | ], 138 | "source": [ 139 | "model.summary()" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 33, 145 | "metadata": { 146 | "collapsed": true 147 | }, 148 | "outputs": [], 149 | "source": [ 150 | "model.compile(loss=\"sparse_categorical_crossentropy\", # sparse_categorical_crossentropy \n", 151 | " optimizer=\"adam\",\n", 152 | " metrics=[\"accuracy\"])" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 34, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "name": "stdout", 162 | "output_type": "stream", 163 | "text": [ 164 | "Epoch 1/1\n", 165 | "60000/60000 [==============================] - 3s 49us/step - loss: 0.4085 - acc: 0.8858\n" 166 | ] 167 | }, 168 | { 169 | "data": { 170 | "text/plain": [ 171 | "" 172 | ] 173 | }, 174 | "execution_count": 34, 175 | "metadata": {}, 176 | "output_type": "execute_result" 177 | } 178 | ], 179 | "source": [ 180 | "model.fit(X_train, y_train)" 181 | ] 182 | }, 183 | { 184 | "cell_type": "code", 185 | "execution_count": 35, 186 | "metadata": {}, 187 | "outputs": [ 188 | { 189 | "name": "stdout", 190 | "output_type": "stream", 191 | "text": [ 192 | "10000/10000 [==============================] - 0s 29us/step\n" 193 | ] 194 | }, 195 | { 196 | "data": { 197 | "text/plain": [ 198 | "[0.23919174144268035, 0.9337]" 199 | ] 200 | }, 201 | "execution_count": 35, 202 | "metadata": {}, 203 | "output_type": "execute_result" 204 | } 205 | ], 206 | "source": [ 207 | "model.evaluate(X_test, y_test)" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 36, 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "data": { 217 | "text/plain": [ 218 | "" 219 | ] 220 | }, 221 | "execution_count": 36, 222 | "metadata": {}, 223 | "output_type": "execute_result" 224 | }, 225 | { 226 | "data": { 227 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQQAAAECCAYAAAAYUakXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADe5JREFUeJzt3X+sX/Vdx/HXa/T2st4W166j1vKj1rHFbo6S3MEW0HRB\nJttCgGzDNZHUZK5EkYBZVNJkgUSdSPghOiUpUtcthckGCNlwhjXTSsSOlpS2tCiIRVsvvUCnLQP6\ng779456+vWP3fr733u+Pcy59PpLm+/2e97nnvHt676ufc76f77mOCAGAJL2j7gYANAeBACARCAAS\ngQAgEQgAEoEAINUSCLYvtv2vtp+zfX0dPZTY3m17u+2ttjc3oJ+1todt7xi1bJ7tR20/Wz3ObVh/\nN9reWx3DrbY/WWN/p9v+vu2dtp+2fW21vBHHsNBfz4+hez0PwfZJkv5N0kWS9kh6QtKKiNjZ00YK\nbO+WNBgRL9fdiyTZ/iVJr0r6WkR8sFp2s6T9EXFTFapzI+L3G9TfjZJejYhb6uhpNNsLJS2MiCdt\nz5G0RdJlkn5dDTiGhf6uUI+PYR0jhHMlPRcRz0fEYUnfkHRpDX1MGxGxUdL+tyy+VNK66vk6jXwD\n1WKc/hojIoYi4snq+UFJuyQtUkOOYaG/nqsjEBZJ+q9Rr/eopr98QUj6nu0ttlfV3cw4FkTEUPX8\nRUkL6mxmHNfY3ladUtR2SjOa7cWSzpG0SQ08hm/pT+rxMeSi4tguiIhlkj4h6epqSNxYMXLe17Q5\n6HdKWiJpmaQhSbfW245ke7ak+yVdFxEHRteacAzH6K/nx7COQNgr6fRRr0+r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gQAgEQgAEoEAIDEP4W3kmd8q3wn/klkHivVWTvuHw+UVYsy76GEaYYQAIBEIABKB\nACARCAASgQAgEQgAEoEAIDEPYRp545Jzi/UNl9zaYguzOtcM3pYYIQBIBAKARCAASAQCgEQgAEgE\nAoBEIABILech2D5d0tckLZAUktZExB22b5T0BUkvVauujohHutUopP8+/6Ri/YwZ7c0zWH/w1GK9\n70D5fgjcDWH6m8jEpKOSvhgRT9qeI2mL7Uer2u0RcUv32gPQSy0DISKGJA1Vzw/a3iVpUbcbA9B7\nk7qGYHuxpHMkbaoWXWN7m+21tsv37wLQeBMOBNuzJd0v6bqIOCDpTklLJC3TyAhizIn0tlfZ3mx7\n8xEd6kDLALplQoFgu08jYbA+Ih6QpIjYFxFvRsQxSXdJGvOTNxGxJiIGI2KwT/2d6htAF7QMBNuW\ndLekXRFx26jlC0etdrmkHZ1vD0AvTeRdhvMlXSlpu+2t1bLVklbYXqaRd5t2S7qqKx0C6JmJvMvw\nmCSPUWLOwTTzx68sLdYf/5XFxXoMbe9gN2giZioCSAQCgEQgAEgEAoBEIABIBAKARCAASI7o3afY\nT/G8OM8X9mx/AEZsig06EPvHmk/0YxghAEgEAoBEIABIBAKARCAASAQCgEQgAEg9nYdg+yVJL4xa\nNF/Syz1rYPLorz1N7q/JvUmd7+/MiHhPq5V6Ggg/sXN7c0QM1tZAC/TXnib31+TepPr645QBQCIQ\nAKS6A2FNzftvhf7a0+T+mtybVFN/tV5DANAsdY8QADQIgQAgEQgAEoEAIBEIANL/ASZ61Xp0/62/\nAAAAAElFTkSuQmCC\n", 228 | "text/plain": [ 229 | "" 230 | ] 231 | }, 232 | "metadata": {}, 233 | "output_type": "display_data" 234 | } 235 | ], 236 | "source": [ 237 | "plt.matshow(X_test[0])" 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": 46, 243 | "metadata": {}, 244 | "outputs": [], 245 | "source": [ 246 | "yp = model.predict(X_test)" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 47, 252 | "metadata": {}, 253 | "outputs": [ 254 | { 255 | "data": { 256 | "text/plain": [ 257 | "array([6.2274383e-05, 5.1421192e-09, 3.7618112e-04, 1.8699981e-03,\n", 258 | " 9.6290319e-07, 6.9304413e-05, 2.5942017e-08, 9.9744511e-01,\n", 259 | " 9.6367085e-06, 1.6648159e-04], dtype=float32)" 260 | ] 261 | }, 262 | "execution_count": 47, 263 | "metadata": {}, 264 | "output_type": "execute_result" 265 | } 266 | ], 267 | "source": [ 268 | "yp[0]" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": 48, 274 | "metadata": {}, 275 | "outputs": [ 276 | { 277 | "data": { 278 | "text/plain": [ 279 | "7" 280 | ] 281 | }, 282 | "execution_count": 48, 283 | "metadata": {}, 284 | "output_type": "execute_result" 285 | } 286 | ], 287 | "source": [ 288 | "np.argmax(yp[0])" 289 | ] 290 | } 291 | ], 292 | "metadata": { 293 | "kernelspec": { 294 | "display_name": "Python 3", 295 | "language": "python", 296 | "name": "python3" 297 | }, 298 | "language_info": { 299 | "codemirror_mode": { 300 | "name": "ipython", 301 | "version": 3 302 | }, 303 | "file_extension": ".py", 304 | "mimetype": "text/x-python", 305 | "name": "python", 306 | "nbconvert_exporter": "python", 307 | "pygments_lexer": "ipython3", 308 | "version": "3.6.8" 309 | } 310 | }, 311 | "nbformat": 4, 312 | "nbformat_minor": 2 313 | } 314 | -------------------------------------------------------------------------------- /1_keras_fashion_mnist_neural_net/Slide1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/1_keras_fashion_mnist_neural_net/Slide1.PNG -------------------------------------------------------------------------------- /1_keras_fashion_mnist_neural_net/Slide2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/1_keras_fashion_mnist_neural_net/Slide2.PNG -------------------------------------------------------------------------------- /1_keras_fashion_mnist_neural_net/classlabels.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/1_keras_fashion_mnist_neural_net/classlabels.JPG -------------------------------------------------------------------------------- /1_keras_fashion_mnist_neural_net/fashion_neural_net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/1_keras_fashion_mnist_neural_net/fashion_neural_net.png -------------------------------------------------------------------------------- /1_keras_fashion_mnist_neural_net/fmnist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/1_keras_fashion_mnist_neural_net/fmnist.png -------------------------------------------------------------------------------- /22_word_embedding/supervised_word_embeddings.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 19, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "from tensorflow.keras.preprocessing.text import one_hot\n", 11 | "from tensorflow.keras.preprocessing.sequence import pad_sequences\n", 12 | "from tensorflow.keras.models import Sequential\n", 13 | "from tensorflow.keras.layers import Dense\n", 14 | "from tensorflow.keras.layers import Flatten\n", 15 | "from tensorflow.keras.layers import Embedding\n", 16 | "\n", 17 | "reviews = ['nice food',\n", 18 | " 'amazing restaurant',\n", 19 | " 'too good',\n", 20 | " 'just loved it!',\n", 21 | " 'will go again',\n", 22 | " 'horrible food',\n", 23 | " 'never go there',\n", 24 | " 'poor service',\n", 25 | " 'poor quality',\n", 26 | " 'needs improvement']\n", 27 | "\n", 28 | "sentiment = np.array([1,1,1,1,1,0,0,0,0,0])" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 20, 34 | "metadata": {}, 35 | "outputs": [ 36 | { 37 | "data": { 38 | "text/plain": [ 39 | "[4, 23]" 40 | ] 41 | }, 42 | "execution_count": 20, 43 | "metadata": {}, 44 | "output_type": "execute_result" 45 | } 46 | ], 47 | "source": [ 48 | "one_hot(\"amazing restaurant\",30)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 21, 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "name": "stdout", 58 | "output_type": "stream", 59 | "text": [ 60 | "[[13, 21], [4, 23], [14, 17], [8, 15, 16], [22, 15, 29], [8, 21], [26, 15, 24], [16, 4], [16, 12], [4, 29]]\n" 61 | ] 62 | } 63 | ], 64 | "source": [ 65 | "vocab_size = 30\n", 66 | "encoded_reviews = [one_hot(d, vocab_size) for d in reviews]\n", 67 | "print(encoded_reviews)" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 22, 73 | "metadata": {}, 74 | "outputs": [ 75 | { 76 | "name": "stdout", 77 | "output_type": "stream", 78 | "text": [ 79 | "[[13 21 0 0]\n", 80 | " [ 4 23 0 0]\n", 81 | " [14 17 0 0]\n", 82 | " [ 8 15 16 0]\n", 83 | " [22 15 29 0]\n", 84 | " [ 8 21 0 0]\n", 85 | " [26 15 24 0]\n", 86 | " [16 4 0 0]\n", 87 | " [16 12 0 0]\n", 88 | " [ 4 29 0 0]]\n" 89 | ] 90 | } 91 | ], 92 | "source": [ 93 | "max_length = 4\n", 94 | "padded_reviews = pad_sequences(encoded_reviews, maxlen=max_length, padding='post')\n", 95 | "print(padded_reviews)" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": 23, 101 | "metadata": { 102 | "scrolled": true 103 | }, 104 | "outputs": [], 105 | "source": [ 106 | "embeded_vector_size = 5\n", 107 | "\n", 108 | "model = Sequential()\n", 109 | "model.add(Embedding(vocab_size, embeded_vector_size, input_length=max_length,name=\"embedding\"))\n", 110 | "model.add(Flatten())\n", 111 | "model.add(Dense(1, activation='sigmoid'))" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": 24, 117 | "metadata": {}, 118 | "outputs": [], 119 | "source": [ 120 | "X = padded_reviews\n", 121 | "y = sentiment" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 25, 127 | "metadata": {}, 128 | "outputs": [ 129 | { 130 | "name": "stdout", 131 | "output_type": "stream", 132 | "text": [ 133 | "Model: \"sequential_1\"\n", 134 | "_________________________________________________________________\n", 135 | "Layer (type) Output Shape Param # \n", 136 | "=================================================================\n", 137 | "embedding (Embedding) (None, 4, 5) 150 \n", 138 | "_________________________________________________________________\n", 139 | "flatten_1 (Flatten) (None, 20) 0 \n", 140 | "_________________________________________________________________\n", 141 | "dense_1 (Dense) (None, 1) 21 \n", 142 | "=================================================================\n", 143 | "Total params: 171\n", 144 | "Trainable params: 171\n", 145 | "Non-trainable params: 0\n", 146 | "_________________________________________________________________\n", 147 | "None\n" 148 | ] 149 | } 150 | ], 151 | "source": [ 152 | "model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])\n", 153 | "print(model.summary())" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 26, 159 | "metadata": { 160 | "scrolled": true 161 | }, 162 | "outputs": [ 163 | { 164 | "data": { 165 | "text/plain": [ 166 | "" 167 | ] 168 | }, 169 | "execution_count": 26, 170 | "metadata": {}, 171 | "output_type": "execute_result" 172 | } 173 | ], 174 | "source": [ 175 | "model.fit(X, y, epochs=50, verbose=0)" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": 29, 181 | "metadata": {}, 182 | "outputs": [ 183 | { 184 | "name": "stdout", 185 | "output_type": "stream", 186 | "text": [ 187 | "1/1 [==============================] - 0s 1ms/step - loss: 0.6384 - accuracy: 1.0000\n" 188 | ] 189 | }, 190 | { 191 | "data": { 192 | "text/plain": [ 193 | "1.0" 194 | ] 195 | }, 196 | "execution_count": 29, 197 | "metadata": {}, 198 | "output_type": "execute_result" 199 | } 200 | ], 201 | "source": [ 202 | "# evaluate the model\n", 203 | "loss, accuracy = model.evaluate(X, y)\n", 204 | "accuracy" 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": 30, 210 | "metadata": {}, 211 | "outputs": [ 212 | { 213 | "data": { 214 | "text/plain": [ 215 | "30" 216 | ] 217 | }, 218 | "execution_count": 30, 219 | "metadata": {}, 220 | "output_type": "execute_result" 221 | } 222 | ], 223 | "source": [ 224 | "weights = model.get_layer('embedding').get_weights()[0]\n", 225 | "len(weights)" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 31, 231 | "metadata": {}, 232 | "outputs": [ 233 | { 234 | "data": { 235 | "text/plain": [ 236 | "array([-0.08330977, -0.06752131, -0.04629624, -0.00765801, -0.02024159],\n", 237 | " dtype=float32)" 238 | ] 239 | }, 240 | "execution_count": 31, 241 | "metadata": {}, 242 | "output_type": "execute_result" 243 | } 244 | ], 245 | "source": [ 246 | "weights[13]" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 32, 252 | "metadata": { 253 | "scrolled": false 254 | }, 255 | "outputs": [ 256 | { 257 | "data": { 258 | "text/plain": [ 259 | "array([-0.07935128, -0.08574004, 0.06615968, -0.02349528, 0.00917289],\n", 260 | " dtype=float32)" 261 | ] 262 | }, 263 | "execution_count": 32, 264 | "metadata": {}, 265 | "output_type": "execute_result" 266 | } 267 | ], 268 | "source": [ 269 | "weights[4]" 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": 33, 275 | "metadata": { 276 | "scrolled": true 277 | }, 278 | "outputs": [ 279 | { 280 | "data": { 281 | "text/plain": [ 282 | "array([ 0.0128377 , 0.03549778, 0.05134471, -0.07147218, 0.03261041],\n", 283 | " dtype=float32)" 284 | ] 285 | }, 286 | "execution_count": 33, 287 | "metadata": {}, 288 | "output_type": "execute_result" 289 | } 290 | ], 291 | "source": [ 292 | "weights[16]" 293 | ] 294 | } 295 | ], 296 | "metadata": { 297 | "kernelspec": { 298 | "display_name": "Python 3", 299 | "language": "python", 300 | "name": "python3" 301 | }, 302 | "language_info": { 303 | "codemirror_mode": { 304 | "name": "ipython", 305 | "version": 3 306 | }, 307 | "file_extension": ".py", 308 | "mimetype": "text/x-python", 309 | "name": "python", 310 | "nbconvert_exporter": "python", 311 | "pygments_lexer": "ipython3", 312 | "version": "3.8.5" 313 | } 314 | }, 315 | "nbformat": 4, 316 | "nbformat_minor": 4 317 | } 318 | -------------------------------------------------------------------------------- /2_activation_functions/2_activation_functions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

Implementation of activation functions in python

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "

Sigmoid

" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "import math\n", 24 | "\n", 25 | "def sigmoid(x):\n", 26 | " return 1 / (1 + math.exp(-x))" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "data": { 36 | "text/plain": [ 37 | "1.0" 38 | ] 39 | }, 40 | "execution_count": 2, 41 | "metadata": {}, 42 | "output_type": "execute_result" 43 | } 44 | ], 45 | "source": [ 46 | "sigmoid(100)" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 3, 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "data": { 56 | "text/plain": [ 57 | "0.7310585786300049" 58 | ] 59 | }, 60 | "execution_count": 3, 61 | "metadata": {}, 62 | "output_type": "execute_result" 63 | } 64 | ], 65 | "source": [ 66 | "sigmoid(1)" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 4, 72 | "metadata": {}, 73 | "outputs": [ 74 | { 75 | "data": { 76 | "text/plain": [ 77 | "4.780892883885469e-25" 78 | ] 79 | }, 80 | "execution_count": 4, 81 | "metadata": {}, 82 | "output_type": "execute_result" 83 | } 84 | ], 85 | "source": [ 86 | "sigmoid(-56)" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": 5, 92 | "metadata": { 93 | "scrolled": false 94 | }, 95 | "outputs": [ 96 | { 97 | "data": { 98 | "text/plain": [ 99 | "0.6224593312018546" 100 | ] 101 | }, 102 | "execution_count": 5, 103 | "metadata": {}, 104 | "output_type": "execute_result" 105 | } 106 | ], 107 | "source": [ 108 | "sigmoid(0.5)" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "

tanh

" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 6, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "def tanh(x):\n", 125 | " return (math.exp(x) - math.exp(-x)) / (math.exp(x) + math.exp(-x))" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 7, 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "data": { 135 | "text/plain": [ 136 | "-1.0" 137 | ] 138 | }, 139 | "execution_count": 7, 140 | "metadata": {}, 141 | "output_type": "execute_result" 142 | } 143 | ], 144 | "source": [ 145 | "tanh(-56)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 8, 151 | "metadata": {}, 152 | "outputs": [ 153 | { 154 | "data": { 155 | "text/plain": [ 156 | "1.0" 157 | ] 158 | }, 159 | "execution_count": 8, 160 | "metadata": {}, 161 | "output_type": "execute_result" 162 | } 163 | ], 164 | "source": [ 165 | "tanh(50)" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 9, 171 | "metadata": {}, 172 | "outputs": [ 173 | { 174 | "data": { 175 | "text/plain": [ 176 | "0.7615941559557649" 177 | ] 178 | }, 179 | "execution_count": 9, 180 | "metadata": {}, 181 | "output_type": "execute_result" 182 | } 183 | ], 184 | "source": [ 185 | "tanh(1)" 186 | ] 187 | }, 188 | { 189 | "cell_type": "markdown", 190 | "metadata": {}, 191 | "source": [ 192 | "

ReLU

" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 10, 198 | "metadata": {}, 199 | "outputs": [], 200 | "source": [ 201 | "def relu(x):\n", 202 | " return max(0,x)" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": 15, 208 | "metadata": {}, 209 | "outputs": [ 210 | { 211 | "data": { 212 | "text/plain": [ 213 | "0" 214 | ] 215 | }, 216 | "execution_count": 15, 217 | "metadata": {}, 218 | "output_type": "execute_result" 219 | } 220 | ], 221 | "source": [ 222 | "relu(-100)" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 14, 228 | "metadata": { 229 | "scrolled": false 230 | }, 231 | "outputs": [ 232 | { 233 | "data": { 234 | "text/plain": [ 235 | "8" 236 | ] 237 | }, 238 | "execution_count": 14, 239 | "metadata": {}, 240 | "output_type": "execute_result" 241 | } 242 | ], 243 | "source": [ 244 | "relu(8)" 245 | ] 246 | }, 247 | { 248 | "cell_type": "markdown", 249 | "metadata": {}, 250 | "source": [ 251 | "

Leaky ReLU

" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 16, 257 | "metadata": {}, 258 | "outputs": [], 259 | "source": [ 260 | "def leaky_relu(x):\n", 261 | " return max(0.1*x,x)" 262 | ] 263 | }, 264 | { 265 | "cell_type": "code", 266 | "execution_count": 17, 267 | "metadata": {}, 268 | "outputs": [ 269 | { 270 | "data": { 271 | "text/plain": [ 272 | "-10.0" 273 | ] 274 | }, 275 | "execution_count": 17, 276 | "metadata": {}, 277 | "output_type": "execute_result" 278 | } 279 | ], 280 | "source": [ 281 | "leaky_relu(-100)" 282 | ] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": 18, 287 | "metadata": {}, 288 | "outputs": [ 289 | { 290 | "data": { 291 | "text/plain": [ 292 | "8" 293 | ] 294 | }, 295 | "execution_count": 18, 296 | "metadata": {}, 297 | "output_type": "execute_result" 298 | } 299 | ], 300 | "source": [ 301 | "leaky_relu(8)" 302 | ] 303 | } 304 | ], 305 | "metadata": { 306 | "kernelspec": { 307 | "display_name": "Python 3", 308 | "language": "python", 309 | "name": "python3" 310 | }, 311 | "language_info": { 312 | "codemirror_mode": { 313 | "name": "ipython", 314 | "version": 3 315 | }, 316 | "file_extension": ".py", 317 | "mimetype": "text/x-python", 318 | "name": "python", 319 | "nbconvert_exporter": "python", 320 | "pygments_lexer": "ipython3", 321 | "version": "3.7.3" 322 | } 323 | }, 324 | "nbformat": 4, 325 | "nbformat_minor": 2 326 | } 327 | -------------------------------------------------------------------------------- /3_derivatives/derivatives_answer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/3_derivatives/derivatives_answer.jpg -------------------------------------------------------------------------------- /3_derivatives/derivatives_exercise.md: -------------------------------------------------------------------------------- 1 | ### Exercise: Derivatives & Partial Derivatives 2 | 3 | ##### Find derivative of following functions 4 | 5 | To find answers please refer to derivatives rules at https://www.mathsisfun.com/calculus/derivatives-rules.html 6 | 7 | 8 | ![](derivatives_question.jpg) 9 | 10 | [Click me for solution of above problems](https://github.com/codebasics/deep-learning-keras-tf-tutorial/blob/main/3_derivatives/derivatives_exercise_solution.md) 11 | 12 | ##### Practice more derivative questions by clicking on link below, 13 | [Derivative Exercise](https://www.mathopolis.com/questions/q.html?id=6800&t=mif&qs=6800_6801_6802_6803_6804_6805_6806_6807_6808_6809_6810_6811_6812&site=1&ref=2f63616c63756c75732f64657269766174697665732d72756c65732e68746d6c&title=446572697661746976652052756c6573) 14 | 15 | ##### Also practice partial derivative questions by clicking on link below, 16 | [Partial Derivatives Exercise](https://www.mathopolis.com/questions/q.html?id=13373&t=mif&qs=13373_13374_13375_13376_13377_13378_13379_13380_13381_13382_13383&site=1&ref=2f63616c63756c75732f64657269766174697665732d7061727469616c2e68746d6c&title=5061727469616c204465726976617469766573) 17 | 18 | 19 | Thanks mathisfun.com for both of above exercises. 20 | -------------------------------------------------------------------------------- /3_derivatives/derivatives_exercise_solution.md: -------------------------------------------------------------------------------- 1 | ![](derivatives_answer.jpg) -------------------------------------------------------------------------------- /3_derivatives/derivatives_question.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/3_derivatives/derivatives_question.jpg -------------------------------------------------------------------------------- /43_distributed_training/small_images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/43_distributed_training/small_images.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/reviews/negative/neg_1.txt: -------------------------------------------------------------------------------- 1 | Basically there's a family where a little boy (Jake) thinks there's a zombie in his closet & his parents are fighting all the time.

This movie is slower than a soap opera... and suddenly, Jake decides to become Rambo and kill the zombie.

OK, first of all when you're going to make a film you must Decide if its a thriller or a drama! As a drama the movie is watchable. Parents are divorcing & arguing like in real life. And then we have Jake with his closet which totally ruins all the film! I expected to see a BOOGEYMAN similar movie, and instead i watched a drama with some meaningless thriller spots.

3 out of 10 just for the well playing parents & descent dialogs. As for the shots with Jake: just ignore them. 2 | -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/reviews/negative/neg_2.txt: -------------------------------------------------------------------------------- 1 | This show was an amazing, fresh & innovative idea in the 70's when it first aired. The first 7 or 8 years were brilliant, but things dropped off after that. By 1990, the show was not really funny anymore, and it's continued its decline further to the complete waste of time it is today.

It's truly disgraceful how far this show has fallen. The writing is painfully bad, the performances are almost as bad - if not for the mildly entertaining respite of the guest-hosts, this show probably wouldn't still be on the air. I find it so hard to believe that the same creator that hand-selected the original cast also chose the band of hacks that followed. How can one recognize such brilliance and then see fit to replace it with such mediocrity? I felt I must give 2 stars out of respect for the original cast that made this show such a huge success. As it is now, the show is just awful. I can't believe it's still on the air. 2 | -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/reviews/negative/neg_3.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/Exercise/reviews/negative/neg_3.txt -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/reviews/positive/pos_1.txt: -------------------------------------------------------------------------------- 1 | One of the other reviewers has mentioned that after watching just 1 Oz episode you'll be hooked. They are right, as this is exactly what happened with me.

The first thing that struck me about Oz was its brutality and unflinching scenes of violence, which set in right from the word GO. Trust me, this is not a show for the faint hearted or timid. This show pulls no punches with regards to drugs, sex or violence. Its is hardcore, in the classic use of the word.

It is called OZ as that is the nickname given to the Oswald Maximum Security State Penitentary. It focuses mainly on Emerald City, an experimental section of the prison where all the cells have glass fronts and face inwards, so privacy is not high on the agenda. Em City is home to many..Aryans, Muslims, gangstas, Latinos, Christians, Italians, Irish and more....so scuffles, death stares, dodgy dealings and shady agreements are never far away.

I would say the main appeal of the show is due to the fact that it goes where other shows wouldn't dare. Forget pretty pictures painted for mainstream audiences, forget charm, forget romance...OZ doesn't mess around. The first episode I ever saw struck me as so nasty it was surreal, I couldn't say I was ready for it, but as I watched more, I developed a taste for Oz, and got accustomed to the high levels of graphic violence. Not just violence, but injustice (crooked guards who'll be sold out for a nickel, inmates who'll kill on order and get away with it, well mannered, middle class inmates being turned into prison bitches due to their lack of street skills or prison experience) Watching Oz, you may become comfortable with what is uncomfortable viewing....thats if you can get in touch with your darker side. 2 | -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/reviews/positive/pos_2.txt: -------------------------------------------------------------------------------- 1 | A wonderful little production.

The filming technique is very unassuming- very old-time-BBC fashion and gives a comforting, and sometimes discomforting, sense of realism to the entire piece.

The actors are extremely well chosen- Michael Sheen not only "has got all the polari" but he has all the voices down pat too! You can truly see the seamless editing guided by the references to Williams' diary entries, not only is it well worth the watching but it is a terrificly written and performed piece. A masterful production about one of the great master's of comedy and his life.

The realism really comes home with the little things: the fantasy of the guard which, rather than use the traditional 'dream' techniques remains solid then disappears. It plays on our knowledge and our senses, particularly with the scenes concerning Orton and Halliwell and the sets (particularly of their flat with Halliwell's murals decorating every surface) are terribly well done. 2 | -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/reviews/positive/pos_3.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/Exercise/reviews/positive/pos_3.txt -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/tf_data_pipeline_exercise.md: -------------------------------------------------------------------------------- 1 | Movie reviews are present as individual text file (one file per review) in review folder. 2 | 3 | Folder structure looks like this, 4 | ``` 5 | reviews 6 | |__ positive 7 | |__pos_1.txt 8 | |__pos_2.txt 9 | |__pos_3.txt 10 | |__ negative 11 | |__neg_1.txt 12 | |__neg_2.txt 13 | |__neg_3.txt 14 | ``` 15 | You need to read these reviews using tf.data.Dataset and perform following transformations, 16 | 17 | 1. Read text review and generate a label from folder name. your dataset should have review text and label as a tuple 18 | 1. Filter blank text review. Two files are blank in this dataset 19 | 1. Do all of the above transformations in single line of code. Also shuffle all the reviews 20 | 21 | [Solution](https://github.com/codebasics/deep-learning-keras-tf-tutorial/tree/master/44_tf_data_pipeline/Exercise/tf_data_pipeline_exercise_solution.ipynb) -------------------------------------------------------------------------------- /44_tf_data_pipeline/Exercise/tf_data_pipeline_exercise_solution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

TF Data Input Pipeline: Exercise Solution

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "Moview reviews are present as individual text file (one file per review) in review folder. \n", 15 | "\n", 16 | "Folder structure looks like this,\n", 17 | "\n", 18 | "reviews\n", 19 | "\n", 20 | " |__ positive\n", 21 | " |__pos_1.txt\n", 22 | " |__pos_2.txt\n", 23 | " |__pos_3.txt\n", 24 | " |__ negative\n", 25 | " |__neg_1.txt\n", 26 | " |__neg_2.txt\n", 27 | " |__neg_3.txt\n", 28 | " \n", 29 | "You need to read these reviews using tf.data.Dataset and perform following transformations,\n", 30 | "\n", 31 | "(1) Read text review and generate a label from folder name. your dataset should have review text and label as a tuple\n", 32 | "\n", 33 | "(2) Filter blank text review. Two files are blank in this dataset\n", 34 | "\n", 35 | "(3) Do all of the above transformations in single line of code. Also shuffle all the reviews" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 168, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "import tensorflow as tf" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "

Retrieve review file paths in a tensorflow dataset

" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 177, 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "reviews_ds = tf.data.Dataset.list_files('reviews/*/*', shuffle=False)" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 178, 66 | "metadata": { 67 | "scrolled": true 68 | }, 69 | "outputs": [ 70 | { 71 | "name": "stdout", 72 | "output_type": "stream", 73 | "text": [ 74 | "b'reviews\\\\negative\\\\neg_1.txt'\n", 75 | "b'reviews\\\\negative\\\\neg_2.txt'\n", 76 | "b'reviews\\\\negative\\\\neg_3.txt'\n", 77 | "b'reviews\\\\positive\\\\pos_1.txt'\n", 78 | "b'reviews\\\\positive\\\\pos_2.txt'\n", 79 | "b'reviews\\\\positive\\\\pos_3.txt'\n" 80 | ] 81 | } 82 | ], 83 | "source": [ 84 | "for file in reviews_ds:\n", 85 | " print(file.numpy())" 86 | ] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "

Extract review text from these files. Extract label from folder name

" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 179, 98 | "metadata": {}, 99 | "outputs": [], 100 | "source": [ 101 | "import os\n", 102 | "def extract_review_and_label(file_path):\n", 103 | " return tf.io.read_file(file_path), tf.strings.split(file_path, os.path.sep)[-2]" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 180, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "name": "stdout", 113 | "output_type": "stream", 114 | "text": [ 115 | "Review: b\"Basically there's a family where a little boy (Jak\"\n", 116 | "Label: b'negative'\n", 117 | "Review: b'This show was an amazing, fresh & innovative idea '\n", 118 | "Label: b'negative'\n", 119 | "Review: b''\n", 120 | "Label: b'negative'\n", 121 | "Review: b'One of the other reviewers has mentioned that afte'\n", 122 | "Label: b'positive'\n", 123 | "Review: b'A wonderful little production.

The fil'\n", 124 | "Label: b'positive'\n", 125 | "Review: b''\n", 126 | "Label: b'positive'\n" 127 | ] 128 | } 129 | ], 130 | "source": [ 131 | "reviews_ds_1 = reviews_ds.map(extract_review_and_label)\n", 132 | "for review, label in reviews_ds_1:\n", 133 | " print(\"Review: \",review.numpy()[:50])\n", 134 | " print(\"Label: \",label.numpy())" 135 | ] 136 | }, 137 | { 138 | "cell_type": "markdown", 139 | "metadata": {}, 140 | "source": [ 141 | "

Filter blank reviews

" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": 181, 147 | "metadata": { 148 | "scrolled": true 149 | }, 150 | "outputs": [ 151 | { 152 | "name": "stdout", 153 | "output_type": "stream", 154 | "text": [ 155 | "Review: b\"Basically there's a family where a little boy (Jak\"\n", 156 | "Label: b'negative'\n", 157 | "Review: b'This show was an amazing, fresh & innovative idea '\n", 158 | "Label: b'negative'\n", 159 | "Review: b'One of the other reviewers has mentioned that afte'\n", 160 | "Label: b'positive'\n", 161 | "Review: b'A wonderful little production.

The fil'\n", 162 | "Label: b'positive'\n" 163 | ] 164 | } 165 | ], 166 | "source": [ 167 | "reviews_ds_2 = reviews_ds_1.filter(lambda review, label: review!=\"\")\n", 168 | "for review, label in reviews_ds_2.as_numpy_iterator():\n", 169 | " print(\"Review: \",review[:50])\n", 170 | " print(\"Label: \",label)" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "

Perform map, filter and shuffle all in single line of code

" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 182, 183 | "metadata": {}, 184 | "outputs": [ 185 | { 186 | "name": "stdout", 187 | "output_type": "stream", 188 | "text": [ 189 | "Review: b'This show was an amazing, fresh & innovative idea '\n", 190 | "Label: b'negative'\n", 191 | "Review: b\"Basically there's a family where a little boy (Jak\"\n", 192 | "Label: b'negative'\n", 193 | "Review: b'A wonderful little production.

The fil'\n", 194 | "Label: b'positive'\n", 195 | "Review: b'One of the other reviewers has mentioned that afte'\n", 196 | "Label: b'positive'\n" 197 | ] 198 | } 199 | ], 200 | "source": [ 201 | "final_ds = reviews_ds.map(extract_review_and_label).filter(lambda review, label: review!=\"\").shuffle(3)\n", 202 | "for review, label in final_ds.as_numpy_iterator():\n", 203 | " print(\"Review:\",review[:50])\n", 204 | " print(\"Label:\",label)" 205 | ] 206 | } 207 | ], 208 | "metadata": { 209 | "kernelspec": { 210 | "display_name": "Python 3", 211 | "language": "python", 212 | "name": "python3" 213 | }, 214 | "language_info": { 215 | "codemirror_mode": { 216 | "name": "ipython", 217 | "version": 3 218 | }, 219 | "file_extension": ".py", 220 | "mimetype": "text/x-python", 221 | "name": "python", 222 | "nbconvert_exporter": "python", 223 | "pygments_lexer": "ipython3", 224 | "version": "3.8.5" 225 | } 226 | }, 227 | "nbformat": 4, 228 | "nbformat_minor": 4 229 | } 230 | -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/20 Reasons Why Cats Make the Best Pets....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/20 Reasons Why Cats Make the Best Pets....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/7 Foods Your Cat Can_t Eat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/7 Foods Your Cat Can_t Eat.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/A cat appears to have caught the....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/A cat appears to have caught the....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Adopt-A-Cat Month® - American Humane....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Adopt-A-Cat Month® - American Humane....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/All About Your Cat_s Tongue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/All About Your Cat_s Tongue.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Alley Cat Allies _ An Advocacy....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Alley Cat Allies _ An Advocacy....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Are Cats Domesticated_ _ The New Yorker.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Are Cats Domesticated_ _ The New Yorker.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Cat Advice _ Collecting a Urine Sample....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Cat Advice _ Collecting a Urine Sample....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Cat Throwing Up_ Normal or Cause for....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Cat Throwing Up_ Normal or Cause for....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Cat intelligence - Wikipedia.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Cat intelligence - Wikipedia.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Cats Care About People More Than Food....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Cats Care About People More Than Food....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Cats _ The Humane Society of the United....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Cats _ The Humane Society of the United....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Cats really do need their humans_ even....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Cats really do need their humans_ even....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/China_s First Cloned Kitten_ Garlic....png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/China_s First Cloned Kitten_ Garlic....png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Famous Cat Performances in Movies_ Ranked.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Famous Cat Performances in Movies_ Ranked.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Giving cats food with an antibody may....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Giving cats food with an antibody may....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Home_ sweet home_ How to bring an....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Home_ sweet home_ How to bring an....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/How to Determine Your Cat_s Age.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/How to Determine Your Cat_s Age.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/How to buy the best cat food_ according....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/How to buy the best cat food_ according....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/International Cat Care _ The ultimate....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/International Cat Care _ The ultimate....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Is My Cat Normal_.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Is My Cat Normal_.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Learn what to do with Stray and Feral....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Learn what to do with Stray and Feral....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/New Cat Checklist 2021_ Supplies for....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/New Cat Checklist 2021_ Supplies for....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Orlando Cat Café.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Orlando Cat Café.png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Pet Insurance for Cats & Kittens _ Petplan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Pet Insurance for Cats & Kittens _ Petplan.png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Reality check_ Can cat poop cause....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Reality check_ Can cat poop cause....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Soon_ the internet will make its own....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Soon_ the internet will make its own....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Stray Cat Alliance » Building a No Kill....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Stray Cat Alliance » Building a No Kill....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Texas lawyer accidentally uses cat....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Texas lawyer accidentally uses cat....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/The 10 Best Types of Cat _ Britannica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/The 10 Best Types of Cat _ Britannica.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/The Cat Health Checklist_ Everything....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/The Cat Health Checklist_ Everything....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/The Joys of Owning a Cat - HelpGuide.org.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/The Joys of Owning a Cat - HelpGuide.org.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/The Science-Backed Benefits of Being a....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/The Science-Backed Benefits of Being a....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Thinking of getting a cat....png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Thinking of getting a cat....png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Urine Marking in Cats _ ASPCA.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Urine Marking in Cats _ ASPCA.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Want your cat to stay in purrrfect....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Want your cat to stay in purrrfect....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/What does the COVID-19 summer surge....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/What does the COVID-19 summer surge....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/What to do if your cat is marking....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/What to do if your cat is marking....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Why Cats Sniff Rear Ends _ VCA Animal....png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Why Cats Sniff Rear Ends _ VCA Animal....png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/cat/Why Do Cats Hate Water_ _ Britannica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/cat/Why Do Cats Hate Water_ _ Britannica.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/10 Teacup Dog Breeds for Tiny Canine Lovers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/10 Teacup Dog Breeds for Tiny Canine Lovers.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/100_ Dogs Pictures _ Download Free....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/100_ Dogs Pictures _ Download Free....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/11 Things Humans Do That Dogs Hate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/11 Things Humans Do That Dogs Hate.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/15 Amazing Facts About Dogs That Will....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/15 Amazing Facts About Dogs That Will....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/20 must-have products for new dog owners.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/20 must-have products for new dog owners.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/25 Best Small Dog Breeds — Cute and....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/25 Best Small Dog Breeds — Cute and....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/25 Low-Maintenance Dog Breeds for....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/25 Low-Maintenance Dog Breeds for....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/2nd pet dog tests positive for COVID-19....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/2nd pet dog tests positive for COVID-19....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/356 Free Dog Stock Photos - CC0 Images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/356 Free Dog Stock Photos - CC0 Images.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/45 Best Large Dog Breeds - Top Big Dogs_yyth....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/45 Best Large Dog Breeds - Top Big Dogs_yyth....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/50 Cutest Dog Breeds as Puppies....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/50 Cutest Dog Breeds as Puppies....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/50 dog breeds and their history that....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/50 dog breeds and their history that....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/66 gifts for dogs or dog lovers to get_yythk....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/66 gifts for dogs or dog lovers to get_yythk....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/7 Tips on Canine Body Language _ ASPCApro.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/7 Tips on Canine Body Language _ ASPCApro.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/8 amazing Indian dog breeds that....png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/8 amazing Indian dog breeds that....png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/9 Reasons to Own a Dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/9 Reasons to Own a Dog.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/AKC Pet Insurance _ Health Insurance....png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/AKC Pet Insurance _ Health Insurance....png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Aggression in dogs _ Animal Humane Society.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Aggression in dogs _ Animal Humane Society.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Ancient dog DNA reveals 11_000 years of....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Ancient dog DNA reveals 11_000 years of....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Are Dogs Really Color-Blind_ _ Britannica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Are Dogs Really Color-Blind_ _ Britannica.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Best Dog & Puppy Health Insurance Plans....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Best Dog & Puppy Health Insurance Plans....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Best Hypoallergenic Dogs [Updated....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Best Hypoallergenic Dogs [Updated....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Body Condition Score....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Body Condition Score....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Calculate Your Dog_s Age With This New....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Calculate Your Dog_s Age With This New....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Canine Mind....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Canine Mind....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Carolina Dog Dog Breed Information....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Carolina Dog Dog Breed Information....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Cats and Dogs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Cats and Dogs.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Colitis in Dogs _ VCA Animal Hospital.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Colitis in Dogs _ VCA Animal Hospital.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Common Dog Breeds and Their Health Issues.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Common Dog Breeds and Their Health Issues.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Dog - Role in human societies _ Britannica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Dog - Role in human societies _ Britannica.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Dog Breed Chart....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Dog Breed Chart....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Dog Breeds Banned By Home Insurance....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Dog Breeds Banned By Home Insurance....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Dog collars _ The Humane Society of the....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Dog collars _ The Humane Society of the....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Dogs _ Healthy Pets_ Healthy People _ CDC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Dogs _ Healthy Pets_ Healthy People _ CDC.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Dogs caught coronavirus from their....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Dogs caught coronavirus from their....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/First dog Major back at White House....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/First dog Major back at White House....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Genes contribute to dog breeds_ iconic....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Genes contribute to dog breeds_ iconic....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Germany_ Dogs must be walked twice a....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Germany_ Dogs must be walked twice a....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Great Dane - Wikipedia.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Great Dane - Wikipedia.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Haunted Victorian Child_ Dog....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Haunted Victorian Child_ Dog....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Hong Kong dog causes panic – but here_s... (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Hong Kong dog causes panic – but here_s... (1).jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Hong Kong dog causes panic – but here_s....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Hong Kong dog causes panic – but here_s....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Hot dogs_ what soaring puppy thefts....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Hot dogs_ what soaring puppy thefts....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/How Many Dog Breeds Are There_ _ Hill_s Pet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/How Many Dog Breeds Are There_ _ Hill_s Pet.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/How My Dog Knows When I_m Sick - The....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/How My Dog Knows When I_m Sick - The....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/How To Read Your Dog_s Body Language....png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/How To Read Your Dog_s Body Language....png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/How dogs contribute to your health and....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/How dogs contribute to your health and....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/How to make your dog feel comfortable....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/How to make your dog feel comfortable....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Important Things Every Dog Owner Should....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Important Things Every Dog Owner Should....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Largest Dog Breeds – American Kennel Club.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Largest Dog Breeds – American Kennel Club.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/List of Dog Breeds _ Petfinder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/List of Dog Breeds _ Petfinder.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/List of dog breeds - Wikipedia.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/List of dog breeds - Wikipedia.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Maltese Dog Breed Information_ Pictures....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Maltese Dog Breed Information_ Pictures....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Modern Dog magazine _ the best dog....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Modern Dog magazine _ the best dog....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Mood-Boosting Benefits of Pets....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Mood-Boosting Benefits of Pets....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Most Expensive Dog Breeds For Pet....png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Most Expensive Dog Breeds For Pet....png -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Most Popular Breeds – American Kennel Club.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Most Popular Breeds – American Kennel Club.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Most Popular Dog Breeds According....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Most Popular Dog Breeds According....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Most Popular Dog Names of 2020....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Most Popular Dog Names of 2020....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Puppy Dog Pictures _ Download Free....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Puppy Dog Pictures _ Download Free....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Rescue turns dog with untreatable tumor....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Rescue turns dog with untreatable tumor....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Rottweiler Dog Breed Information....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Rottweiler Dog Breed Information....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Science_ Talking to Your Dog Means You....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Science_ Talking to Your Dog Means You....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Service Dogs from Southeastern Guide Dogs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Service Dogs from Southeastern Guide Dogs.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Soi Dog Foundation _ Ending The... (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Soi Dog Foundation _ Ending The... (1).jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Soi Dog Foundation _ Ending The....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Soi Dog Foundation _ Ending The....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Southeastern Guide Dogs - YouTube.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Southeastern Guide Dogs - YouTube.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Subaru Shows Love for Dogs Through the....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Subaru Shows Love for Dogs Through the....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The 20 Best Dog Breeds for Runners....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The 20 Best Dog Breeds for Runners....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The 25 Cutest Dog Breeds - Most....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The 25 Cutest Dog Breeds - Most....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The Best Dogs of BBC Earth _ Top 5....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The Best Dogs of BBC Earth _ Top 5....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The Black Dog Tavern Company _ Life off....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The Black Dog Tavern Company _ Life off....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The Cost of Owning a Dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The Cost of Owning a Dog.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The History of Dogs as Pets - ABC News.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The History of Dogs as Pets - ABC News.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The Importance of Walking Your Dog....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The Importance of Walking Your Dog....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/The US Army is testing augmented....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/The US Army is testing augmented....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Those Puppy Dog Eyes You Can_t Resist....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Those Puppy Dog Eyes You Can_t Resist....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Top 10 Smartest Dog Breeds - Most....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Top 10 Smartest Dog Breeds - Most....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Trained dogs can smell coronavirus in....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Trained dogs can smell coronavirus in....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Welcoming Your Adopted Dog Into Your....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Welcoming Your Adopted Dog Into Your....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/What makes dogs so special and....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/What makes dogs so special and....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Which Pop Culture Dog Is Best in Show....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Which Pop Culture Dog Is Best in Show....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/Why Grumpy Dogs Outperform Friendly....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/Why Grumpy Dogs Outperform Friendly....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/been calculating dog years wrong....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/been calculating dog years wrong....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/best dog treats_ according to veterinarians.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/best dog treats_ according to veterinarians.jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/convert dog years to human years....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/convert dog years to human years....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/dog existed at the end of the Ice Age_yythkg....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/dog existed at the end of the Ice Age_yythkg....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/real_ age_ you_ll need a calculator....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/real_ age_ you_ll need a calculator....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/scientists explain puppy dog eyes....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/scientists explain puppy dog eyes....jpg -------------------------------------------------------------------------------- /44_tf_data_pipeline/images/dog/why dogs understand our body language....jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/44_tf_data_pipeline/images/dog/why dogs understand our body language....jpg -------------------------------------------------------------------------------- /45_prefatch/prefetch_caching.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

Optimize tensorflow pipeline performance with prefetch and caching

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 14, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import tensorflow as tf\n", 17 | "import time" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 15, 23 | "metadata": { 24 | "scrolled": true 25 | }, 26 | "outputs": [ 27 | { 28 | "data": { 29 | "text/plain": [ 30 | "'2.5.0'" 31 | ] 32 | }, 33 | "execution_count": 15, 34 | "metadata": {}, 35 | "output_type": "execute_result" 36 | } 37 | ], 38 | "source": [ 39 | "tf.__version__" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": {}, 45 | "source": [ 46 | "

Prefetch

" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 16, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "class FileDataset(tf.data.Dataset):\n", 56 | " def read_file_in_batches(num_samples):\n", 57 | " # Opening the file\n", 58 | " time.sleep(0.03)\n", 59 | "\n", 60 | " for sample_idx in range(num_samples):\n", 61 | " # Reading data (line, record) from the file\n", 62 | " time.sleep(0.015)\n", 63 | "\n", 64 | " yield (sample_idx,)\n", 65 | "\n", 66 | " def __new__(cls, num_samples=3):\n", 67 | " return tf.data.Dataset.from_generator(\n", 68 | " cls.read_file_in_batches,\n", 69 | " output_signature = tf.TensorSpec(shape = (1,), dtype = tf.int64),\n", 70 | " args=(num_samples,)\n", 71 | " )" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 17, 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [ 80 | "def benchmark(dataset, num_epochs=2):\n", 81 | " for epoch_num in range(num_epochs):\n", 82 | " for sample in dataset:\n", 83 | " # Performing a training step\n", 84 | " time.sleep(0.01)" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 18, 90 | "metadata": { 91 | "scrolled": true 92 | }, 93 | "outputs": [ 94 | { 95 | "name": "stdout", 96 | "output_type": "stream", 97 | "text": [ 98 | "304 ms ± 10.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" 99 | ] 100 | } 101 | ], 102 | "source": [ 103 | "%%timeit\n", 104 | "benchmark(FileDataset())" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 23, 110 | "metadata": {}, 111 | "outputs": [ 112 | { 113 | "name": "stdout", 114 | "output_type": "stream", 115 | "text": [ 116 | "238 ms ± 6.64 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" 117 | ] 118 | } 119 | ], 120 | "source": [ 121 | "%%timeit\n", 122 | "benchmark(FileDataset().prefetch(1))" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 19, 128 | "metadata": {}, 129 | "outputs": [ 130 | { 131 | "name": "stdout", 132 | "output_type": "stream", 133 | "text": [ 134 | "240 ms ± 7.28 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" 135 | ] 136 | } 137 | ], 138 | "source": [ 139 | "%%timeit\n", 140 | "benchmark(FileDataset().prefetch(tf.data.AUTOTUNE))" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "**As you can notice above, using prefetch improves the performance from 304 ms to 238 and 240 ms**" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "

Cache

" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 30, 160 | "metadata": {}, 161 | "outputs": [ 162 | { 163 | "data": { 164 | "text/plain": [ 165 | "[0, 1, 4, 9, 16]" 166 | ] 167 | }, 168 | "execution_count": 30, 169 | "metadata": {}, 170 | "output_type": "execute_result" 171 | } 172 | ], 173 | "source": [ 174 | "dataset = tf.data.Dataset.range(5)\n", 175 | "dataset = dataset.map(lambda x: x**2)\n", 176 | "dataset = dataset.cache(\"mycache.txt\")\n", 177 | "# The first time reading through the data will generate the data using\n", 178 | "# `range` and `map`.\n", 179 | "list(dataset.as_numpy_iterator())" 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": 29, 185 | "metadata": {}, 186 | "outputs": [ 187 | { 188 | "data": { 189 | "text/plain": [ 190 | "[0, 1, 4, 9, 16]" 191 | ] 192 | }, 193 | "execution_count": 29, 194 | "metadata": {}, 195 | "output_type": "execute_result" 196 | } 197 | ], 198 | "source": [ 199 | "# Subsequent iterations read from the cache.\n", 200 | "list(dataset.as_numpy_iterator())" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": 24, 206 | "metadata": {}, 207 | "outputs": [], 208 | "source": [ 209 | "def mapped_function(s):\n", 210 | " # Do some hard pre-processing\n", 211 | " tf.py_function(lambda: time.sleep(0.03), [], ())\n", 212 | " return s" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": 26, 218 | "metadata": {}, 219 | "outputs": [ 220 | { 221 | "name": "stdout", 222 | "output_type": "stream", 223 | "text": [ 224 | "1.25 s ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)\n" 225 | ] 226 | } 227 | ], 228 | "source": [ 229 | "%%timeit -r1 -n1\n", 230 | "benchmark(FileDataset().map(mapped_function), 5)" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": 27, 236 | "metadata": {}, 237 | "outputs": [ 238 | { 239 | "name": "stdout", 240 | "output_type": "stream", 241 | "text": [ 242 | "528 ms ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)\n" 243 | ] 244 | } 245 | ], 246 | "source": [ 247 | "%%timeit -r1 -n1\n", 248 | "benchmark(FileDataset().map(mapped_function).cache(), 5)" 249 | ] 250 | }, 251 | { 252 | "cell_type": "markdown", 253 | "metadata": {}, 254 | "source": [ 255 | "**Further reading** https://www.tensorflow.org/guide/data_performance#caching" 256 | ] 257 | } 258 | ], 259 | "metadata": { 260 | "kernelspec": { 261 | "display_name": "Python 3", 262 | "language": "python", 263 | "name": "python3" 264 | }, 265 | "language_info": { 266 | "codemirror_mode": { 267 | "name": "ipython", 268 | "version": 3 269 | }, 270 | "file_extension": ".py", 271 | "mimetype": "text/x-python", 272 | "name": "python", 273 | "nbconvert_exporter": "python", 274 | "pygments_lexer": "ipython3", 275 | "version": "3.8.5" 276 | } 277 | }, 278 | "nbformat": 4, 279 | "nbformat_minor": 4 280 | } 281 | -------------------------------------------------------------------------------- /48_tf_serving/models.config.a: -------------------------------------------------------------------------------- 1 | model_config_list { 2 | config { 3 | name: 'email_model' 4 | base_path: '/48_tf_serving/saved_models' 5 | model_platform: 'tensorflow' 6 | model_version_policy: {all: {}} 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /48_tf_serving/models.config.b: -------------------------------------------------------------------------------- 1 | model_config_list { 2 | config { 3 | name: 'email_model' 4 | base_path: '/48_tf_serving/saved_models' 5 | model_platform: 'tensorflow' 6 | model_version_policy: { 7 | specific: { 8 | versions: 2 9 | versions: 3 10 | } 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /48_tf_serving/models.config.c: -------------------------------------------------------------------------------- 1 | model_config_list { 2 | config { 3 | name: 'email_model' 4 | base_path: '/48_tf_serving/saved_models' 5 | model_platform: 'tensorflow' 6 | model_version_policy { 7 | specific { 8 | versions: 1 9 | versions: 2 10 | } 11 | } 12 | version_labels { 13 | key: 'production' 14 | value: 1 15 | } 16 | version_labels { 17 | key: 'beta' 18 | value: 2 19 | } 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /48_tf_serving/readme.md: -------------------------------------------------------------------------------- 1 | To start docker container 2 | ========================== 3 | ``` 4 | docker run -it -v C:\Code\deep-learning-keras-tf-tutorial\48_tf_serving:/48_tf_serving -p 8601:8601 --entrypoint /bin/bash tensorflow/serving 5 | ``` 6 | 7 | To serve only latest model 8 | =========================== 9 | ``` 10 | tensorflow_model_server --rest_api_port=8601 --model_name=email_model --model_base_path=/48_tf_serving/saved_models/ 11 | ``` 12 | 13 | To serve models using model config file 14 | ======================================== 15 | ``` 16 | tensorflow_model_server --rest_api_port=8601 --allow_version_labels_for_unavailable_models --model_config_file=/48_tf_serving/model.config.c 17 | ``` 18 | 19 | 20 | Postman commands 21 | ================= 22 | 23 | To call by versions 24 | ``` 25 | http://localhost:8601/v1/models/email_model/versions/2:predict 26 | ``` 27 | 28 | To call by labels 29 | ``` 30 | http://localhost:8601/v1/models/email_model/labels/beta:predict 31 | ``` 32 | 33 | Body: raw 34 | ``` 35 | { 36 | "instances": [ 37 | "Let's meet for dinner tomorrow", 38 | "You are awarded a SiPix Digital Camera! call 09061221061 from landline. Delivery within 28days. T Cs Box177" 39 | ] 40 | } 41 | ``` 42 | 43 | TF Serving Installation Instructions & Config File Help 44 | ======================================================= 45 | 46 | https://www.tensorflow.org/tfx/serving/docker 47 | https://www.tensorflow.org/tfx/serving/serving_config -------------------------------------------------------------------------------- /4_matrix_math/4_matrix_math.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "

Calculate profit/loss from revenue and expenses

" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 4, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "revenue = np.array([[180,200,220],[24,36,40],[12,18,20]])\n", 26 | "expenses = np.array([[80,90,100],[10,16,20],[8,10,10]])" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 5, 32 | "metadata": { 33 | "scrolled": true 34 | }, 35 | "outputs": [ 36 | { 37 | "data": { 38 | "text/plain": [ 39 | "array([[100, 110, 120],\n", 40 | " [ 14, 20, 20],\n", 41 | " [ 4, 8, 10]])" 42 | ] 43 | }, 44 | "execution_count": 5, 45 | "metadata": {}, 46 | "output_type": "execute_result" 47 | } 48 | ], 49 | "source": [ 50 | "profit = revenue - expenses\n", 51 | "profit" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "

Calculate total sales from units and price per unit using matrix multiplication

" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 6, 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "price_per_unit = np.array([1000,400,1200])\n", 68 | "units = np.array([[30,40,50],[5,10,15],[2,5,7]])" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 7, 74 | "metadata": { 75 | "scrolled": true 76 | }, 77 | "outputs": [ 78 | { 79 | "data": { 80 | "text/plain": [ 81 | "array([[30000, 16000, 60000],\n", 82 | " [ 5000, 4000, 18000],\n", 83 | " [ 2000, 2000, 8400]])" 84 | ] 85 | }, 86 | "execution_count": 7, 87 | "metadata": {}, 88 | "output_type": "execute_result" 89 | } 90 | ], 91 | "source": [ 92 | "price_per_unit*units" 93 | ] 94 | }, 95 | { 96 | "cell_type": "markdown", 97 | "metadata": {}, 98 | "source": [ 99 | "In above case numpy is using broadcasting so it expands price_per_unit array from 1 row, 3 columns to 3 row and 3 columns. Correct way to do matrix multiplication is to use dot product as shown below" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 8, 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "data": { 109 | "text/plain": [ 110 | "array([34400, 50000, 64400])" 111 | ] 112 | }, 113 | "execution_count": 8, 114 | "metadata": {}, 115 | "output_type": "execute_result" 116 | } 117 | ], 118 | "source": [ 119 | "np.dot(price_per_unit,units)" 120 | ] 121 | } 122 | ], 123 | "metadata": { 124 | "kernelspec": { 125 | "display_name": "Python 3", 126 | "language": "python", 127 | "name": "python3" 128 | }, 129 | "language_info": { 130 | "codemirror_mode": { 131 | "name": "ipython", 132 | "version": 3 133 | }, 134 | "file_extension": ".py", 135 | "mimetype": "text/x-python", 136 | "name": "python", 137 | "nbconvert_exporter": "python", 138 | "pygments_lexer": "ipython3", 139 | "version": "3.7.3" 140 | } 141 | }, 142 | "nbformat": 4, 143 | "nbformat_minor": 2 144 | } 145 | -------------------------------------------------------------------------------- /4_matrix_math/4_matrix_math.md: -------------------------------------------------------------------------------- 1 | #### Exercise: Matrix Math 2 | 1. Below is some indian companies revenues in US dollars. Using numpy can you convert this into Indian rupees? 1 USD = 75 INR 3 | 4 | ![](revenue_usd.jpg) 5 | 6 | 2. Divine flowers is a flower shop that sells different type of flowers. Below is the table showing how many flowers of each type they sold in different months. Also given are the prices of one flower each. Using this find out their total sales in every month. 7 | 8 | ![](flowers.jpg) 9 | 10 | [Click here for solution of 1 and 2](https://github.com/codebasics/deep-learning-keras-tf-tutorial/blob/main/4_matrix_math/4_matrix_math_exercise_solution.ipynb) 11 | 12 | 3. Here is some matrix exercise from mathisfun.com. Please click on a link below and do the exercise. 13 | 14 | [Click me for matrix exercise](https://www.mathopolis.com/questions/q.html?id=714&t=mif&qs=714_715_716_717_2394_2395_2397_2396_8473_8474_8475_8476&site=1&ref=2f616c67656272612f6d61747269782d6d756c7469706c79696e672e68746d6c&title=486f7720746f204d756c7469706c79204d61747269636573) 15 | 16 | -------------------------------------------------------------------------------- /4_matrix_math/4_matrix_math_exercise_solution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "metadata": { 7 | "scrolled": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "import numpy as np" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "

Solution 1: Convert USD revenues to INR

" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 4, 24 | "metadata": {}, 25 | "outputs": [ 26 | { 27 | "data": { 28 | "text/plain": [ 29 | "array([[15000, 16500, 18750],\n", 30 | " [ 5100, 5925, 7875],\n", 31 | " [ 8250, 10500, 13500],\n", 32 | " [ 6000, 6375, 6750]])" 33 | ] 34 | }, 35 | "execution_count": 4, 36 | "metadata": {}, 37 | "output_type": "execute_result" 38 | } 39 | ], 40 | "source": [ 41 | "revenues_usd = np.array([[200,220,250],[68,79,105],[110,140,180],[80,85,90]])\n", 42 | "revenues_inr = 75*revenues_usd\n", 43 | "revenues_inr" 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "metadata": {}, 49 | "source": [ 50 | "

Solution 2: Calculate total flowers sale every month for divine flowers shop

" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 6, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "units_sold = np.array([[50,60,25],[10,13,5],[40,70,52]])\n", 60 | "price_per_unit = np.array([20,30,15])" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 7, 66 | "metadata": {}, 67 | "outputs": [ 68 | { 69 | "data": { 70 | "text/plain": [ 71 | "array([1900, 2640, 1430])" 72 | ] 73 | }, 74 | "execution_count": 7, 75 | "metadata": {}, 76 | "output_type": "execute_result" 77 | } 78 | ], 79 | "source": [ 80 | "total_sales_amount = np.dot(price_per_unit,units_sold)\n", 81 | "total_sales_amount" 82 | ] 83 | } 84 | ], 85 | "metadata": { 86 | "kernelspec": { 87 | "display_name": "Python 3", 88 | "language": "python", 89 | "name": "python3" 90 | }, 91 | "language_info": { 92 | "codemirror_mode": { 93 | "name": "ipython", 94 | "version": 3 95 | }, 96 | "file_extension": ".py", 97 | "mimetype": "text/x-python", 98 | "name": "python", 99 | "nbconvert_exporter": "python", 100 | "pygments_lexer": "ipython3", 101 | "version": "3.7.3" 102 | } 103 | }, 104 | "nbformat": 4, 105 | "nbformat_minor": 2 106 | } 107 | -------------------------------------------------------------------------------- /4_matrix_math/flowers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/4_matrix_math/flowers.jpg -------------------------------------------------------------------------------- /4_matrix_math/matrix_math.camproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1920 6 | 1080 7 | 1 8 | 1 9 | -1 10 | 11 | 12 | 13 | C:\Users\Viral\AppData\Local\TechSmith\Camtasia Studio\8.0\Auto-Saves\matrix_mathf7afe9c.autosave.camproj 14 | 15 | D1DA6B9C-4372-493C-9B7C-69479602BC48 16 | 17 | 0 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 8 28 | matrix_math 29 | 30 | 31 | 13 32 | 2020-08-03 05:36:47 PM 33 | 34 | 35 | 16 36 | ENU 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | -------------------------------------------------------------------------------- /4_matrix_math/matrix_math_theory.trec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/4_matrix_math/matrix_math_theory.trec -------------------------------------------------------------------------------- /4_matrix_math/revenue_usd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/4_matrix_math/revenue_usd.jpg -------------------------------------------------------------------------------- /5_loss/5_loss_or_cost_function.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 3, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "y_predicted = np.array([1,1,0,0,1])\n", 19 | "y_true = np.array([0.30,0.7,1,0,0.5])" 20 | ] 21 | }, 22 | { 23 | "cell_type": "markdown", 24 | "metadata": {}, 25 | "source": [ 26 | "

Implement Mean Absolute Error

" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 4, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "def mae(y_predicted, y_true):\n", 36 | " total_error = 0\n", 37 | " for yp, yt in zip(y_predicted, y_true):\n", 38 | " total_error += abs(yp - yt)\n", 39 | " print(\"Total error is:\",total_error)\n", 40 | " mae = total_error/len(y_predicted)\n", 41 | " print(\"Mean absolute error is:\",mae)\n", 42 | " return mae" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 5, 48 | "metadata": { 49 | "scrolled": true 50 | }, 51 | "outputs": [ 52 | { 53 | "name": "stdout", 54 | "output_type": "stream", 55 | "text": [ 56 | "Total error is: 2.5\n", 57 | "Mean absolute error is: 0.5\n" 58 | ] 59 | }, 60 | { 61 | "data": { 62 | "text/plain": [ 63 | "0.5" 64 | ] 65 | }, 66 | "execution_count": 5, 67 | "metadata": {}, 68 | "output_type": "execute_result" 69 | } 70 | ], 71 | "source": [ 72 | "mae(y_predicted, y_true)" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "**Implement same thing using numpy in much easier way**" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 32, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "data": { 89 | "text/plain": [ 90 | "array([0.5, 0.5, 0. , 0. , 0.3])" 91 | ] 92 | }, 93 | "execution_count": 32, 94 | "metadata": {}, 95 | "output_type": "execute_result" 96 | } 97 | ], 98 | "source": [ 99 | "np.abs(y_predicted-y_true)" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 33, 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "data": { 109 | "text/plain": [ 110 | "0.26" 111 | ] 112 | }, 113 | "execution_count": 33, 114 | "metadata": {}, 115 | "output_type": "execute_result" 116 | } 117 | ], 118 | "source": [ 119 | "np.mean(np.abs(y_predicted-y_true))" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": 34, 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [ 128 | "def mae_np(y_predicted, y_true):\n", 129 | " return np.mean(np.abs(y_predicted-y_true))" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": 35, 135 | "metadata": { 136 | "scrolled": true 137 | }, 138 | "outputs": [ 139 | { 140 | "data": { 141 | "text/plain": [ 142 | "0.26" 143 | ] 144 | }, 145 | "execution_count": 35, 146 | "metadata": {}, 147 | "output_type": "execute_result" 148 | } 149 | ], 150 | "source": [ 151 | "mae_np(y_predicted, y_true)" 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": {}, 157 | "source": [ 158 | "

Implement Log Loss or Binary Cross Entropy

" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": 79, 164 | "metadata": {}, 165 | "outputs": [ 166 | { 167 | "name": "stderr", 168 | "output_type": "stream", 169 | "text": [ 170 | ":1: RuntimeWarning: divide by zero encountered in log\n", 171 | " np.log([0])\n" 172 | ] 173 | }, 174 | { 175 | "data": { 176 | "text/plain": [ 177 | "array([-inf])" 178 | ] 179 | }, 180 | "execution_count": 79, 181 | "metadata": {}, 182 | "output_type": "execute_result" 183 | } 184 | ], 185 | "source": [ 186 | "np.log([0])" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 59, 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [ 195 | "epsilon = 1e-15" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 58, 201 | "metadata": {}, 202 | "outputs": [ 203 | { 204 | "data": { 205 | "text/plain": [ 206 | "array([-34.53877639])" 207 | ] 208 | }, 209 | "execution_count": 58, 210 | "metadata": {}, 211 | "output_type": "execute_result" 212 | } 213 | ], 214 | "source": [ 215 | "np.log([1e-15])" 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": 61, 221 | "metadata": {}, 222 | "outputs": [ 223 | { 224 | "data": { 225 | "text/plain": [ 226 | "array([1, 1, 0, 0, 1])" 227 | ] 228 | }, 229 | "execution_count": 61, 230 | "metadata": {}, 231 | "output_type": "execute_result" 232 | } 233 | ], 234 | "source": [ 235 | "y_predicted" 236 | ] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "execution_count": 68, 241 | "metadata": { 242 | "scrolled": true 243 | }, 244 | "outputs": [ 245 | { 246 | "data": { 247 | "text/plain": [ 248 | "[1, 1, 1e-15, 1e-15, 1]" 249 | ] 250 | }, 251 | "execution_count": 68, 252 | "metadata": {}, 253 | "output_type": "execute_result" 254 | } 255 | ], 256 | "source": [ 257 | "y_predicted_new = [max(i,epsilon) for i in y_predicted]\n", 258 | "y_predicted_new" 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": 70, 264 | "metadata": {}, 265 | "outputs": [ 266 | { 267 | "data": { 268 | "text/plain": [ 269 | "0.999999999999999" 270 | ] 271 | }, 272 | "execution_count": 70, 273 | "metadata": {}, 274 | "output_type": "execute_result" 275 | } 276 | ], 277 | "source": [ 278 | "1-epsilon" 279 | ] 280 | }, 281 | { 282 | "cell_type": "code", 283 | "execution_count": 69, 284 | "metadata": {}, 285 | "outputs": [ 286 | { 287 | "data": { 288 | "text/plain": [ 289 | "[0.999999999999999, 0.999999999999999, 1e-15, 1e-15, 0.999999999999999]" 290 | ] 291 | }, 292 | "execution_count": 69, 293 | "metadata": {}, 294 | "output_type": "execute_result" 295 | } 296 | ], 297 | "source": [ 298 | "y_predicted_new = [min(i,1-epsilon) for i in y_predicted_new]\n", 299 | "y_predicted_new" 300 | ] 301 | }, 302 | { 303 | "cell_type": "code", 304 | "execution_count": 74, 305 | "metadata": {}, 306 | "outputs": [], 307 | "source": [ 308 | "y_predicted_new = np.array(y_predicted_new)" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 71, 314 | "metadata": {}, 315 | "outputs": [ 316 | { 317 | "data": { 318 | "text/plain": [ 319 | "array([-9.99200722e-16, -9.99200722e-16, -3.45387764e+01, -3.45387764e+01,\n", 320 | " -9.99200722e-16])" 321 | ] 322 | }, 323 | "execution_count": 71, 324 | "metadata": {}, 325 | "output_type": "execute_result" 326 | } 327 | ], 328 | "source": [ 329 | "np.log(y_predicted_new)" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": 75, 335 | "metadata": {}, 336 | "outputs": [ 337 | { 338 | "data": { 339 | "text/plain": [ 340 | "17.2696280766844" 341 | ] 342 | }, 343 | "execution_count": 75, 344 | "metadata": {}, 345 | "output_type": "execute_result" 346 | } 347 | ], 348 | "source": [ 349 | "-np.mean(y_true*np.log(y_predicted_new)+(1-y_true)*np.log(1-y_predicted_new))" 350 | ] 351 | }, 352 | { 353 | "cell_type": "code", 354 | "execution_count": 76, 355 | "metadata": {}, 356 | "outputs": [], 357 | "source": [ 358 | "def log_loss(y_true, y_predicted):\n", 359 | " y_predicted_new = [max(i,epsilon) for i in y_predicted]\n", 360 | " y_predicted_new = [min(i,1-epsilon) for i in y_predicted_new]\n", 361 | " y_predicted_new = np.array(y_predicted_new)\n", 362 | " return -np.mean(y_true*np.log(y_predicted_new)+(1-y_true)*np.log(1-y_predicted_new))" 363 | ] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": 77, 368 | "metadata": { 369 | "scrolled": true 370 | }, 371 | "outputs": [ 372 | { 373 | "data": { 374 | "text/plain": [ 375 | "17.2696280766844" 376 | ] 377 | }, 378 | "execution_count": 77, 379 | "metadata": {}, 380 | "output_type": "execute_result" 381 | } 382 | ], 383 | "source": [ 384 | "log_loss(y_true, y_predicted)" 385 | ] 386 | }, 387 | { 388 | "cell_type": "markdown", 389 | "metadata": {}, 390 | "source": [ 391 | "

Exercise

" 392 | ] 393 | }, 394 | { 395 | "cell_type": "markdown", 396 | "metadata": {}, 397 | "source": [ 398 | "Implement mean squared error (or MSE) in two ways,\n", 399 | "\n", 400 | "1) Without using numpy (i.e. using plain python)\n", 401 | "\n", 402 | "2) With the use of numpy" 403 | ] 404 | }, 405 | { 406 | "cell_type": "markdown", 407 | "metadata": {}, 408 | "source": [ 409 | "[Solution](https://github.com/codebasics/deep-learning-keras-tf-tutorial/blob/main/5_loss/loss_function_exercise_solution.ipynb)" 410 | ] 411 | } 412 | ], 413 | "metadata": { 414 | "kernelspec": { 415 | "display_name": "Python 3", 416 | "language": "python", 417 | "name": "python3" 418 | }, 419 | "language_info": { 420 | "codemirror_mode": { 421 | "name": "ipython", 422 | "version": 3 423 | }, 424 | "file_extension": ".py", 425 | "mimetype": "text/x-python", 426 | "name": "python", 427 | "nbconvert_exporter": "python", 428 | "pygments_lexer": "ipython3", 429 | "version": "3.8.3" 430 | } 431 | }, 432 | "nbformat": 4, 433 | "nbformat_minor": 4 434 | } -------------------------------------------------------------------------------- /5_loss/loss_function_exercise_solution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

Loss function exercise: Implement Mean Squared Error Function In Python

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "You need to implement mean squared error function first without using numpy and then using numpy" 15 | ] 16 | }, 17 | { 18 | "cell_type": "markdown", 19 | "metadata": {}, 20 | "source": [ 21 | "

Solution 1: Without using numpy

" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 1, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "import numpy as np\n", 31 | "\n", 32 | "y_predicted = np.array([1,1,0,0,1])\n", 33 | "y_true = np.array([0.30,0.7,1,0,0.5])" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 30, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "def mse(y_true, y_predicted):\n", 43 | " total_error = 0\n", 44 | " for yt, yp in zip(y_true, y_predicted):\n", 45 | " total_error += (yt-yp)**2\n", 46 | " print(\"Total Squared Error:\",total_error)\n", 47 | " mse = total_error/len(y_true)\n", 48 | " print(\"Mean Squared Error:\",mse)\n", 49 | " return mse" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 31, 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "Total Squared Error: 1.83\n", 62 | "Mean Squared Error: 0.366\n" 63 | ] 64 | }, 65 | { 66 | "data": { 67 | "text/plain": [ 68 | "0.366" 69 | ] 70 | }, 71 | "execution_count": 31, 72 | "metadata": {}, 73 | "output_type": "execute_result" 74 | } 75 | ], 76 | "source": [ 77 | "mse(y_true, y_predicted)" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "metadata": {}, 83 | "source": [ 84 | "

Solution 2: By using numpy

" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 32, 90 | "metadata": {}, 91 | "outputs": [ 92 | { 93 | "data": { 94 | "text/plain": [ 95 | "0.366" 96 | ] 97 | }, 98 | "execution_count": 32, 99 | "metadata": {}, 100 | "output_type": "execute_result" 101 | } 102 | ], 103 | "source": [ 104 | "np.mean(np.square(y_true-y_predicted))" 105 | ] 106 | } 107 | ], 108 | "metadata": { 109 | "kernelspec": { 110 | "display_name": "Python 3", 111 | "language": "python", 112 | "name": "python3" 113 | }, 114 | "language_info": { 115 | "codemirror_mode": { 116 | "name": "ipython", 117 | "version": 3 118 | }, 119 | "file_extension": ".py", 120 | "mimetype": "text/x-python", 121 | "name": "python", 122 | "nbconvert_exporter": "python", 123 | "pygments_lexer": "ipython3", 124 | "version": "3.8.3" 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 4 129 | } 130 | -------------------------------------------------------------------------------- /6_gradient_descent/insurance_data.csv: -------------------------------------------------------------------------------- 1 | age,affordibility,bought_insurance 2 | 22,1,0 3 | 25,0,0 4 | 47,1,1 5 | 52,0,0 6 | 46,1,1 7 | 56,1,1 8 | 55,0,0 9 | 60,0,1 10 | 62,1,1 11 | 61,1,1 12 | 18,1,0 13 | 28,1,0 14 | 27,0,0 15 | 29,0,0 16 | 49,1,1 17 | 55,1,1 18 | 25,0,1 19 | 58,1,1 20 | 19,0,0 21 | 18,1,0 22 | 21,1,0 23 | 26,0,0 24 | 40,1,1 25 | 45,1,1 26 | 50,1,1 27 | 54,1,1 28 | 23,1,0 29 | 46,1,0 30 | -------------------------------------------------------------------------------- /6_gradient_descent/nn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/6_gradient_descent/nn.png -------------------------------------------------------------------------------- /7_nn_from_scratch/insurance_data.csv: -------------------------------------------------------------------------------- 1 | age,affordibility,bought_insurance 2 | 22,1,0 3 | 25,0,0 4 | 47,1,1 5 | 52,0,0 6 | 46,1,1 7 | 56,1,1 8 | 55,0,0 9 | 60,0,1 10 | 62,1,1 11 | 61,1,1 12 | 18,1,0 13 | 28,1,0 14 | 27,0,0 15 | 29,0,0 16 | 49,1,1 17 | 55,1,1 18 | 25,0,1 19 | 58,1,1 20 | 19,0,0 21 | 18,1,0 22 | 21,1,0 23 | 26,0,0 24 | 40,1,1 25 | 45,1,1 26 | 50,1,1 27 | 54,1,1 28 | 23,1,0 29 | 46,1,0 30 | -------------------------------------------------------------------------------- /7_nn_from_scratch/nn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/7_nn_from_scratch/nn.jpg -------------------------------------------------------------------------------- /8_sgd_vs_gd/gradient_descent.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def gradient_descent(x,y,epochs): 4 | m_curr = b_curr = 0 5 | n = len(x) 6 | learning_rate = 0.08 7 | 8 | for i in range(epochs): 9 | y_predicted = m_curr * x + b_curr 10 | cost = (1/n) * sum([val**2 for val in (y-y_predicted)]) 11 | md = -(2/n)*sum(x*(y-y_predicted)) 12 | bd = -(2/n)*sum(y-y_predicted) 13 | m_curr = m_curr - learning_rate * md 14 | b_curr = b_curr - learning_rate * bd 15 | print ("m {}, b {}, cost {} iteration {}".format(m_curr,b_curr,cost, i)) 16 | 17 | x = np.array([1,2,3,4,5]) 18 | y = np.array([5,7,9,11,13]) 19 | 20 | gradient_descent(x,y, 500) -------------------------------------------------------------------------------- /8_sgd_vs_gd/homeprices.csv: -------------------------------------------------------------------------------- 1 | area,bedrooms,age,price 2 | 2600,3,20,550000 3 | 3000,4,15,565000 4 | 3200,3,18,610000 5 | 3600,3,30,595000 6 | 4000,5,8,760000 7 | 4100,6,8,810000 8 | -------------------------------------------------------------------------------- /8_sgd_vs_gd/homeprices_banglore.csv: -------------------------------------------------------------------------------- 1 | area,bedrooms,price 2 | 1056,2,39.07 3 | 2600,4,120 4 | 1440,3,62 5 | 1521,3,75 6 | 1200,2,51 7 | 1170,2,38 8 | 2732,4,135 9 | 3300,4,155 10 | 1310,3,50 11 | 3700,5,167 12 | 1800,3,82 13 | 2785,4,140 14 | 1000,2,38 15 | 1100,2,40 16 | 2250,3,101 17 | 1175,2,42 18 | 1180,3,48 19 | 1540,3,60 20 | 2770,3,102 21 | 800,1,32 22 | -------------------------------------------------------------------------------- /8_sgd_vs_gd/hp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebasics/deep-learning-keras-tf-tutorial/0981fe55db7a7abf19ff1d852d9a59153289641e/8_sgd_vs_gd/hp.jpg -------------------------------------------------------------------------------- /8_sgd_vs_gd/mini_batch_gd_exercise_solution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

Implement mini batch gradient descent

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "data": { 17 | "text/html": [ 18 | "
\n", 19 | "\n", 32 | "\n", 33 | " \n", 34 | " \n", 35 | " \n", 36 | " \n", 37 | " \n", 38 | " \n", 39 | " \n", 40 | " \n", 41 | " \n", 42 | " \n", 43 | " \n", 44 | " \n", 45 | " \n", 46 | " \n", 47 | " \n", 48 | " \n", 49 | " \n", 50 | " \n", 51 | " \n", 52 | " \n", 53 | " \n", 54 | " \n", 55 | " \n", 56 | " \n", 57 | " \n", 58 | " \n", 59 | " \n", 60 | " \n", 61 | " \n", 62 | " \n", 63 | " \n", 64 | " \n", 65 | " \n", 66 | " \n", 67 | " \n", 68 | " \n", 69 | " \n", 70 | " \n", 71 | " \n", 72 | " \n", 73 | "
areabedroomsprice
171540360.0
151175242.0
51170238.0
126004120.0
81310350.0
\n", 74 | "
" 75 | ], 76 | "text/plain": [ 77 | " area bedrooms price\n", 78 | "17 1540 3 60.0\n", 79 | "15 1175 2 42.0\n", 80 | "5 1170 2 38.0\n", 81 | "1 2600 4 120.0\n", 82 | "8 1310 3 50.0" 83 | ] 84 | }, 85 | "execution_count": 2, 86 | "metadata": {}, 87 | "output_type": "execute_result" 88 | } 89 | ], 90 | "source": [ 91 | "import pandas as pd\n", 92 | "import numpy as np\n", 93 | "from matplotlib import pyplot as plt\n", 94 | "%matplotlib inline\n", 95 | "\n", 96 | "df = pd.read_csv(\"homeprices_banglore.csv\")\n", 97 | "df.sample(5)" 98 | ] 99 | } 100 | ], 101 | "metadata": { 102 | "kernelspec": { 103 | "display_name": "Python 3", 104 | "language": "python", 105 | "name": "python3" 106 | }, 107 | "language_info": { 108 | "codemirror_mode": { 109 | "name": "ipython", 110 | "version": 3 111 | }, 112 | "file_extension": ".py", 113 | "mimetype": "text/x-python", 114 | "name": "python", 115 | "nbconvert_exporter": "python", 116 | "pygments_lexer": "ipython3", 117 | "version": "3.8.5" 118 | } 119 | }, 120 | "nbformat": 4, 121 | "nbformat_minor": 4 122 | } 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Deep Learning using Tensorflow 2.0 and Keras](https://www.youtube.com/playlist?list=PLeo1K3hjS3uu7CxAacxVndI4bE_o3BDtO) 2 | Learn deep learning with tensorflow2.0, keras and python through this comprehensive deep learning tutorial series. Learn deep learning from scratch. Deep learning series for beginners. Tensorflow tutorials, tensorflow 2.0 tutorial. deep learning tutorial python. 3 | --------------------------------------------------------------------------------