├── 1. Introduction to TensorFlow ├── README.md ├── week 1 │ ├── Graded Assignments │ │ ├── C1W1_Assignment.ipynb │ │ └── week1-quiz.md │ ├── README.md │ └── img │ │ ├── capture-1.PNG │ │ ├── capture-2.PNG │ │ ├── capture-3.PNG │ │ └── week1-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6.PNG │ │ └── 7.PNG ├── week 2 │ ├── Graded Assignment │ │ ├── C1W2_Assignment.ipynb │ │ └── week2-quiz.md │ ├── README.md │ └── img │ │ ├── capture-1.PNG │ │ ├── capture-2.PNG │ │ └── week2-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ └── 6.PNG ├── week 3 │ ├── Graded Assignment │ │ ├── C1W3_Assignment.ipynb │ │ └── week3-quiz.md │ ├── README.md │ └── img │ │ ├── capture-1.PNG │ │ ├── capture-2.PNG │ │ └── week3-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ └── 5.PNG └── week 4 │ ├── Graded Assignment │ ├── C1W4_Assignment.ipynb │ └── week4-quiz.md │ ├── README.md │ └── img │ └── week4-quiz │ ├── 1.PNG │ ├── 2.PNG │ ├── 3.PNG │ ├── 4.PNG │ ├── 5.PNG │ ├── 6.PNG │ └── 7.PNG ├── 2. Convolutional Neural Networks in TensorFlow ├── tf-course2-lecture-notes │ ├── C2_W1.pdf │ ├── C2_W2.pdf │ ├── C2_W3.pdf │ └── C2_W4.pdf ├── week-1 │ ├── Graded Assignments │ │ ├── C2W1_Assignment.ipynb │ │ └── week1-quiz.md │ └── img │ │ └── week1-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6.PNG │ │ ├── 7.PNG │ │ └── 8.PNG ├── week-2 │ ├── Graded Assignments │ │ ├── C2W2_Assignment.ipynb │ │ └── week2-quiz.md │ └── img │ │ └── week2-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6.PNG │ │ ├── 7.PNG │ │ └── 8.PNG ├── week-3 │ ├── Graded Assignments │ │ ├── C2W3_Assignment.ipynb │ │ └── week3-quiz.md │ └── img │ │ └── week3-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6.PNG │ │ ├── 7.PNG │ │ └── 8.PNG └── week-4 │ ├── Graded Assignments │ ├── Copy_of_C2W3_Assignment.ipynb │ └── week4-quiz.md │ └── img │ └── week4-quiz │ ├── 1.PNG │ ├── 2.PNG │ ├── 3.PNG │ ├── 4.PNG │ ├── 5.PNG │ ├── 6.PNG │ ├── 7.PNG │ └── 8.PNG ├── 3. Natural Language Processing in TensorFlow ├── week-1 │ ├── Graded Assignments │ │ ├── C3W1_Assignment.ipynb │ │ └── week1-quiz.md │ ├── README.md │ ├── img │ │ ├── oov.PNG │ │ ├── padding.PNG │ │ ├── practice-1.PNG │ │ ├── sarcastic-dataset.PNG │ │ ├── sequences.PNG │ │ └── week1-quiz │ │ │ ├── 1.PNG │ │ │ ├── 2.PNG │ │ │ ├── 3.PNG │ │ │ ├── 4.PNG │ │ │ ├── 5.PNG │ │ │ ├── 6.PNG │ │ │ ├── 7.PNG │ │ │ └── 8.PNG │ └── practice.md ├── week-2 │ ├── Graded Assignments │ │ ├── C3W2_Assignment.ipynb │ │ ├── Tensorflow Embedding Projector │ │ │ ├── meta.tsv │ │ │ └── vecs.tsv │ │ └── week2-quiz.md │ ├── README.md │ └── img │ │ ├── tfds.png │ │ └── week2-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6.PNG │ │ ├── 7.PNG │ │ └── 8.PNG └── week-3 │ ├── Graded Assignment │ └── week3-quiz.md │ ├── README.md │ └── img │ ├── 50epoch-loss.PNG │ ├── 50epoch.PNG │ ├── acc-loss.PNG │ ├── bidirection-lstm.PNG │ ├── comp-acc.PNG │ ├── comp-loss.PNG │ ├── function.PNG │ ├── lstm.PNG │ ├── model-summary-2.PNG │ ├── model-summary.PNG │ ├── neural-network.PNG │ ├── rnn.PNG │ └── week3-quiz │ ├── 1.PNG │ ├── 2.PNG │ ├── 3.PNG │ ├── 4.PNG │ ├── 5.PNG │ ├── 6.PNG │ ├── 7.PNG │ └── 8.PNG ├── 4. Sequences, Time Series and Prediction ├── lecture-notes │ ├── C4_W1.pdf │ ├── C4_W2.pdf │ ├── C4_W3.pdf │ └── C4_W4.pdf ├── week-1 │ ├── Graded Assignment │ │ ├── C4W1_Assignment.ipynb │ │ └── week1-quiz.md │ ├── README.md │ └── img │ │ ├── birth-and-date.PNG │ │ ├── fixed-partitioning.PNG │ │ ├── metrics.PNG │ │ ├── roll-forward-partitioning.PNG │ │ └── week1-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6.PNG │ │ ├── 7.PNG │ │ ├── 8.PNG │ │ └── 9.PNG ├── week-2 │ ├── Graded Assignment │ │ ├── C4W2_Assignment.ipynb │ │ ├── my_model.h5 │ │ └── week2-quiz.md │ └── img │ │ └── week2-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6 (1).PNG │ │ ├── 6 (2).PNG │ │ ├── 6.PNG │ │ ├── 7.PNG │ │ ├── 8.PNG │ │ └── 9.PNG ├── week-3 │ ├── Graded Assignment │ │ └── week3-quiz.md │ ├── README.md │ └── img │ │ ├── recurrent-layer.PNG │ │ └── week3-quiz │ │ ├── 1.PNG │ │ ├── 2.PNG │ │ ├── 3.PNG │ │ ├── 4.PNG │ │ ├── 5.PNG │ │ ├── 6.PNG │ │ ├── 7.PNG │ │ └── 8.PNG └── week-4 │ ├── Graded Assignment │ └── week4-quiz.md │ └── img │ └── week4-quiz │ ├── 1.PNG │ ├── 2.PNG │ ├── 3.PNG │ ├── 4.PNG │ ├── 5.PNG │ ├── 6.PNG │ ├── 7.PNG │ └── 8.PNG ├── C2W3_Assignment.ipynb └── README.md /1. Introduction to TensorFlow/README.md: -------------------------------------------------------------------------------- 1 | # Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning 2 | 3 | ## About this Course 4 | This course is part of the upcoming Machine Learning in Tensorflow Specialization and will teach you best practices for using TensorFlow, a popular open-source framework for machine learning. 5 | 6 | The Machine Learning course and Deep Learning Specialization from Andrew Ng teach the most important and foundational principles of Machine Learning and Deep Learning. This new deeplearning.ai TensorFlow Specialization teaches you how to use TensorFlow to implement those principles so that you can start building and applying scalable models to real-world problems. To develop a deeper understanding of how neural networks work, we recommend that you take the Deep Learning Specialization. 7 | 8 | ## Syllabus 9 | * [Week 1](week%201/) A New Programming Paradigm
10 | Soft introduction to what Machine Learning and Deep Learning are, and how they offer a new programming paradigm, giving a new set of tools to open previously unexplored scenarios. 11 | * [Week 2](week%202/) Introduction to Computer Vision 12 | * [Week 3](week%203/) Enhancing Vision with Convolutional Neural Networks 13 | * [Week 4](week%204/) Using Real-world Images -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/Graded Assignments/week1-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 1 2 | 3 | week-1-quiz 4 | 5 | week-1-quiz 6 | 7 | week-1-quiz 8 | 9 | week-1-quiz 10 | 11 | week-1-quiz 12 | 13 | week-1-quiz 14 | 15 | week-1-quiz 16 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/README.md: -------------------------------------------------------------------------------- 1 | # A New Programming Paradigm 2 | 3 | ## An Overview 4 | * One of the best tools we can use to implement deep learning and machine learning algorithms is TensorFlow. 5 | * Programming frameworks like TensorFlow, PyTorchm caffe and many others can help us in learning algorithms, moreover they can save a lot of time. 6 | * Deep learning and machine learning skills are becoming ever more important and opening up whole new scenarios. 7 | * Even though the whole world sees the promise and the hope of these machine learning AI capabilities changing so many things, the world just doesn't have enough AI developers today. 8 | 9 | ## Notebooks for This Course 10 | Ungraded labs and assignment for each week can be found in this [Github repository](https://github.com/https-deeplearning-ai/tensorflow-1-public). 11 | How to run the notebooks locally: 12 | ``` 13 | git clone https://github.com/https-deeplearning-ai/tensorflow-1-public 14 | git pull 15 | ``` 16 | Packages: 17 | ``` 18 | tensorflow==2.7.0 19 | scikit-learn==1.0.1 20 | pandas==1.1.5 21 | matplotlib==3.2.2 22 | seaborn==0.11.2 23 | ``` 24 | 25 | ## A Primer in Machine Learning 26 |

27 | traditional-programming 28 |

29 |

Image 1. Traditional Programming

30 | 31 |

32 | activity-recognition 33 |

34 |

Image 2. Activity Recognition using Traditional Programming

35 | 36 |

37 | new-programming 38 |

39 |

Image 3. New Programming

40 | 41 | * Rules are express in a programming language and data can come from a variety of sources from local variables or the way up to databases 42 | * Machine learning is really similar but we only flipping the axes 43 | * Neural network is the workhorse of doing this type of pattern recognition 44 | 45 | ## The ‘Hello World’ of neural networks 46 | Machine learning is all about a computer learning the patterns that distinguish things. The simplest possible neural network is one that has only one neuron in it, we can see it the code below. 47 | 48 | ```python 49 | # # In keras, we use Dense to define a layer of connected neurons 50 | model = keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])]) 51 | model.compile(optimizer='sgd', loss='mean_squared_error') 52 | 53 | xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float) 54 | ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype-float) 55 | 56 | # the training takes place in the fit command 57 | # epoch = 500, means that it will go through the training loop 500 times 58 | model.fit(xs, ys, epochs=500) 59 | 60 | print(model.predict([10.0])) 61 | ``` 62 | 63 | There are two functions, **loss** and **optimizer**. 64 | * Loss function measure how good or how bad its guess was. Loss function is mean squarred error. 65 | * Optimizer function figures out the next guess, how good or how badly the guess was done using the data from the loss function. Each guess should be better than the one before. Optimizer is SGD (Stochastic Gradient Descent) 66 | 67 | In conclusion, the steps to figure out the patterns are: 68 | 1. Make a guess 69 | 2. Measure how good or how bad the guesses with the loss function 70 | 3. Use the optimizer and the data to make another guess and repeat this 71 | 72 | If the result is far from expectation or what you guess before, there are 2 reasons for it. 73 | 1. Training data is too small 74 | 2. When using neural networks, they deal in probability as they try to figure out the answers for everything. 75 | 76 | ## From Rules to Data 77 | * Traditional paradigm of expressing rules in a coding language may not always work to solve a problem. Computer vision are very difficult to solve with rules-based programming. 78 | * We can feed a computer with enough data that we describe / label as what we want it to recognize. Example: fitting numbers to a line. 79 | 80 | ## Get started with Google Colaboratory (Coding TensorFlow) 81 | 82 | * One useful notebook collection: [Seedbank Project](research.google.com/seedbank) 83 | * Start working with Google Colab: [Welcome to Colaboratory](colab.research.google.com) 84 | * An easy way to learn and use Tensorflow in Colab: [Colab - Tensorflow](https://medium.com/tensorflow/colab-an-easy-way-to-learn-and-use-tensorflow-d74d1686e309) 85 | * Week 1 - Workbook: [Hello World of Deep Learning with Neural Networks](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C1/W1/ungraded_lab/C1_W1_Lab_1_hello_world_nn.ipynb) 86 | 87 | ## Week 1 Grading Assignments 88 | 89 | * Quiz 1: [week1-quiz](Graded%20Assignments/week1-quiz.md) 90 | * Programming assignment: [notebook](Graded%20Assignments/C1W1_Assignment.ipynb) 91 | 92 | ## Resources 93 | * AI for everyone: [ai-for-everyone-course](https://www.deeplearning.ai/program/ai-for-everyone/) 94 | * Tensorflow: [documentation](https://www.tensorflow.org/) and [youtube](https://www.youtube.com/tensorflow) 95 | * Play with neural networks: [neural-network](http://playground.tensorflow.org/#activation=tanh&batchSize=10&dataset=circle®Dataset=reg-plane&learningRate=0.03®ularizationRate=0&noise=0&networkShape=4,2&seed=0.83151&showTestData=false&discretize=false&percTrainData=50&x=true&y=true&xTimesY=false&xSquared=false&ySquared=false&cosX=false&sinX=false&cosY=false&sinY=false&collectStats=false&problem=classification&initZero=false&hideText=false) -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/capture-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/capture-1.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/capture-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/capture-2.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/capture-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/capture-3.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/week1-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/week1-quiz/1.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/week1-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/week1-quiz/2.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/week1-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/week1-quiz/3.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/week1-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/week1-quiz/4.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/week1-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/week1-quiz/5.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/week1-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/week1-quiz/6.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 1/img/week1-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 1/img/week1-quiz/7.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/Graded Assignment/C1W2_Assignment.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "_2s0EJ5Fy4u2" 7 | }, 8 | "source": [ 9 | "# Week 2: Implementing Callbacks in TensorFlow using the MNIST Dataset\n", 10 | "\n", 11 | "In the course you learned how to do classification using Fashion MNIST, a data set containing items of clothing. There's another, similar dataset called MNIST which has items of handwriting -- the digits 0 through 9.\n", 12 | "\n", 13 | "Write an MNIST classifier that trains to 99% accuracy or above, and does it without a fixed number of epochs -- i.e. you should stop training once you reach that level of accuracy. In the lecture you saw how this was done for the loss but here you will be using accuracy instead.\n", 14 | "\n", 15 | "Some notes:\n", 16 | "1. Given the architecture of the net, it should succeed in less than 10 epochs.\n", 17 | "2. When it reaches 99% or greater it should print out the string \"Reached 99% accuracy so cancelling training!\" and stop training.\n", 18 | "3. If you add any additional variables, make sure you use the same names as the ones used in the class. This is important for the function signatures (the parameters and names) of the callbacks." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": { 25 | "id": "djVOgMHty4u3" 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "import os\n", 30 | "import tensorflow as tf\n", 31 | "from tensorflow import keras" 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "metadata": {}, 37 | "source": [ 38 | "Begin by loading the data. A couple of things to notice:\n", 39 | "\n", 40 | "- The file `mnist.npz` is already included in the current workspace under the `data` directory. By default the `load_data` from Keras accepts a path relative to `~/.keras/datasets` but in this case it is stored somewhere else, as a result of this, you need to specify the full path.\n", 41 | "\n", 42 | "- `load_data` returns the train and test sets in the form of the tuples `(x_train, y_train), (x_test, y_test)` but in this exercise you will be needing only the train set so you can ignore the second tuple." 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 2, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "# Load the data\n", 52 | "\n", 53 | "# Get current working directory\n", 54 | "current_dir = os.getcwd()\n", 55 | "\n", 56 | "# Append data/mnist.npz to the previous path to get the full path\n", 57 | "data_path = os.path.join(current_dir, \"data/mnist.npz\")\n", 58 | "\n", 59 | "# Discard test set\n", 60 | "(x_train, y_train), _ = tf.keras.datasets.mnist.load_data(path=data_path)\n", 61 | " \n", 62 | "# Normalize pixel values\n", 63 | "x_train = x_train / 255.0" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "Now take a look at the shape of the training data:" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": 3, 76 | "metadata": {}, 77 | "outputs": [ 78 | { 79 | "name": "stdout", 80 | "output_type": "stream", 81 | "text": [ 82 | "There are 60000 examples with shape (28, 28)\n" 83 | ] 84 | } 85 | ], 86 | "source": [ 87 | "data_shape = x_train.shape\n", 88 | "\n", 89 | "print(f\"There are {data_shape[0]} examples with shape ({data_shape[1]}, {data_shape[2]})\")" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "metadata": {}, 95 | "source": [ 96 | "Now it is time to create your own custom callback. For this complete the `myCallback` class and the `on_epoch_end` method in the cell below. If you need some guidance on how to proceed, check out this [link](https://www.tensorflow.org/guide/keras/custom_callback)." 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 10, 102 | "metadata": {}, 103 | "outputs": [], 104 | "source": [ 105 | "# GRADED CLASS: myCallback\n", 106 | "### START CODE HERE\n", 107 | "\n", 108 | "# Remember to inherit from the correct class\n", 109 | "class myCallback(tf.keras.callbacks.Callback):\n", 110 | " # Define the correct function signature for on_epoch_end\n", 111 | " def on_epoch_end(self, epoch, logs={}):\n", 112 | " if logs.get('accuracy') is not None and logs.get('accuracy') > 0.99:\n", 113 | " print(\"\\nReached 99% accuracy so cancelling training!\") \n", 114 | " \n", 115 | " # Stop training once the above condition is met\n", 116 | " self.model.stop_training = True\n", 117 | "\n", 118 | "### END CODE HERE\n" 119 | ] 120 | }, 121 | { 122 | "cell_type": "markdown", 123 | "metadata": {}, 124 | "source": [ 125 | "Now that you have defined your callback it is time to complete the `train_mnist` function below:" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 13, 131 | "metadata": { 132 | "id": "rEHcB3kqyHZ6" 133 | }, 134 | "outputs": [], 135 | "source": [ 136 | "# GRADED FUNCTION: train_mnist\n", 137 | "def train_mnist(x_train, y_train):\n", 138 | "\n", 139 | " ### START CODE HERE\n", 140 | " \n", 141 | " # Instantiate the callback class\n", 142 | " callbacks = myCallback()\n", 143 | " \n", 144 | " # Define the model, it should have 3 layers:\n", 145 | " # - A Flatten layer that receives inputs with the same shape as the images\n", 146 | " # - A Dense layer with 512 units and ReLU activation function\n", 147 | " # - A Dense layer with 10 units and softmax activation function\n", 148 | " model = tf.keras.models.Sequential([ \n", 149 | " tf.keras.layers.Flatten(input_shape=(28,28)),\n", 150 | " tf.keras.layers.Dense(512, activation=tf.nn.relu),\n", 151 | " tf.keras.layers.Dense(10, activation=tf.nn.softmax)\n", 152 | " ]) \n", 153 | "\n", 154 | " # Compile the model\n", 155 | " model.compile(optimizer='adam', \n", 156 | " loss='sparse_categorical_crossentropy', \n", 157 | " metrics=['accuracy']) \n", 158 | " \n", 159 | " # Fit the model for 10 epochs adding the callbacks\n", 160 | " # and save the training history\n", 161 | " history = model.fit(x_train, y_train, epochs=10, callbacks=[callbacks])\n", 162 | "\n", 163 | " ### END CODE HERE\n", 164 | "\n", 165 | " return history" 166 | ] 167 | }, 168 | { 169 | "cell_type": "markdown", 170 | "metadata": {}, 171 | "source": [ 172 | "Call the `train_mnist` passing in the appropiate parameters to get the training history:" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": 14, 178 | "metadata": { 179 | "id": "sFgpwbGly4u4" 180 | }, 181 | "outputs": [ 182 | { 183 | "name": "stdout", 184 | "output_type": "stream", 185 | "text": [ 186 | "Epoch 1/10\n", 187 | "1875/1875 [==============================] - 8s 4ms/step - loss: 0.1990 - accuracy: 0.9420\n", 188 | "Epoch 2/10\n", 189 | "1875/1875 [==============================] - 7s 4ms/step - loss: 0.0820 - accuracy: 0.9749\n", 190 | "Epoch 3/10\n", 191 | "1875/1875 [==============================] - 7s 4ms/step - loss: 0.0523 - accuracy: 0.9837\n", 192 | "Epoch 4/10\n", 193 | "1875/1875 [==============================] - 7s 4ms/step - loss: 0.0377 - accuracy: 0.9873\n", 194 | "Epoch 5/10\n", 195 | "1870/1875 [============================>.] - ETA: 0s - loss: 0.0269 - accuracy: 0.9912\n", 196 | "Reached 99% accuracy so cancelling training!\n", 197 | "1875/1875 [==============================] - 7s 4ms/step - loss: 0.0269 - accuracy: 0.9912\n" 198 | ] 199 | } 200 | ], 201 | "source": [ 202 | "hist = train_mnist(x_train, y_train)" 203 | ] 204 | }, 205 | { 206 | "cell_type": "markdown", 207 | "metadata": {}, 208 | "source": [ 209 | "If you see the message `Reached 99% accuracy so cancelling training!` printed out after less than 10 epochs it means your callback worked as expected. " 210 | ] 211 | }, 212 | { 213 | "cell_type": "markdown", 214 | "metadata": {}, 215 | "source": [ 216 | "**Congratulations on finishing this week's assignment!**\n", 217 | "\n", 218 | "You have successfully implemented a callback that gives you more control over the training loop for your model. Nice job!\n", 219 | "\n", 220 | "**Keep it up!**" 221 | ] 222 | } 223 | ], 224 | "metadata": { 225 | "jupytext": { 226 | "main_language": "python" 227 | }, 228 | "kernelspec": { 229 | "display_name": "Python 3", 230 | "language": "python", 231 | "name": "python3" 232 | }, 233 | "language_info": { 234 | "codemirror_mode": { 235 | "name": "ipython", 236 | "version": 3 237 | }, 238 | "file_extension": ".py", 239 | "mimetype": "text/x-python", 240 | "name": "python", 241 | "nbconvert_exporter": "python", 242 | "pygments_lexer": "ipython3", 243 | "version": "3.8.8" 244 | } 245 | }, 246 | "nbformat": 4, 247 | "nbformat_minor": 4 248 | } 249 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/Graded Assignment/week2-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 2 2 | 3 | week-2-quiz 4 | 5 | week-2-quiz 6 | 7 | week-2-quiz 8 | 9 | week-2-quiz 10 | 11 | week-2-quiz 12 | 13 | week-2-quiz 14 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/README.md: -------------------------------------------------------------------------------- 1 | # Introduction to Computer Vision 2 | 3 | Computer vision is the field of having a computer understand and label what is present in an image. Can you figure out how can we tell the computer to recognize fashion image? Yes, we use lots of pictures of clothing and tell the computer what that's a picture of and then have the computer figure out the patterns that give you the difference between a shoe, and a shirt, and a handbag, and a coat 4 | 5 | ## Fashion MNIST Dataset 6 | The [Fashion MNIST Dataset](https://github.com/zalandoresearch/fashion-mnist) is a collection of grayscale 28x28 pixel clothing images. 7 |

8 | fashion-mnist
9 | Image 1. Fashion Images Dataset 10 |

11 | 12 | For image resolution, the smaller the better it becomes because the computer has less processing to do. But of course, we need to retain enough information to be sure that the features and the object can still be distinguished. 13 | 14 | ## Writing code to load training data 15 | ```python 16 | import tensorflow as tf 17 | from tensorflow import keras 18 | 19 | # declare object, loading it from the keras database 20 | fashion_mnist = tf.keras.dataseets.fashion_mnist 21 | 22 | # (training data, training labels), (testing data, testing labels) 23 | (train_images, train_labels), (test_images, test_labels) = fashion_minst.load_data() 24 | ``` 25 | 26 | We use 60,000 images for training the model and 10,000 left for testing it. 27 | 28 | ## The structure of Fashion MNIST data 29 | The labels are represented by a number. Using a number is a first step in avoiding bias (instead of labelling it with words in a specific language). 30 | 31 | Learn more about how to avoid bias [here](https://ai.google/responsibilities/responsible-ai-practices/). 32 | 33 | ## Coding a Computer Vision Neural Network 34 | ```python 35 | import tensorflow as tf 36 | from tf import keras 37 | 38 | model = keras.Sequential([ 39 | # img resolution 28 x 28 40 | # turns in into a simple linear array 41 | keras.layers.Flattern(input_shape=(28,28)), 42 | 43 | # hidden layer 44 | 45 | keras.layers.Dense(128, activation=tf.nn.relu), 46 | 47 | # units = 10, represents 10 classes of clothing 48 | keras.layers.Dense(10, activation=tf.nn.softmax) 49 | ]) 50 | ``` 51 | 52 |

53 | fashion-mnist
54 | Image 2. Neural Network Layers 55 |

56 | 57 | ## Using Callbacks to control training 58 | 59 | When you’re done with that, the next thing to do is to explore callbacks. One of the things you can do with that is to train a neural network until it reaches a threshold you want, and then stop training. You’ll see that in the next video. 60 | 61 | How can I stop training when I reach a point that I want to be at? Training loop does support callbacks. 62 | 63 | ```python 64 | mnist = tf.keras.datasets.fashion_mnist 65 | (training_images, training_labels), (test_images, test_labels) = mnist.load_data() 66 | training_images = training_images/255.0 67 | test_images = test_images/255.0 68 | model = tf.keras.models.Sequential([ 69 | tf.keras.layers.Flatten(), 70 | tf.keras.layers.Dense(512, activation=tf.nn.relu), 71 | tf.keras.layers.Dense(10, activation=tf.nn.softmax) 72 | ]) 73 | model.compile(optimizer='adam', loss='sparse_categorical_crossentropy') 74 | model.fit(training_images, training_labels, epochs=5) 75 | 76 | model.evaluate(test_images, test_labels) 77 | ``` 78 | 79 | Callbacks function. 80 | ```python 81 | class myCallback(tf.keras.callbacks.Callback): 82 | def on_epoch_end(self, epoch, logs={}): 83 | if(logs.get('loss')<0.4): 84 | print("\nLoss is low so canceling training!") 85 | self.model.stop_training = True 86 | ``` 87 | 88 | Then the code will look like this. 89 | ```python 90 | # here is your Callbacks function 91 | ... 92 | 93 | # calling callbacks 94 | callbacks = myCallback() 95 | 96 | # here is the rest of uour code 97 | ... 98 | ... 99 | ... 100 | 101 | # modification 102 | model.fit(training_images, training_labels, epochs=5, callbacks=[callbacks]) 103 | ``` 104 | 105 | ## Ungraded Lab 106 | * Lab 1: [Get hands-on with computer vision](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C1/W2/ungraded_labs/C1_W2_Lab_1_beyond_hello_world.ipynb) 107 | * Lab 2: [See how to implement Callbacks](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C1/W2/ungraded_labs/C1_W2_Lab_2_callbacks.ipynb) 108 | 109 | ## Other Datasets 110 | Find more `tf.keras.datasets` API [here](https://www.tensorflow.org/api_docs/python/tf/keras/datasets). 111 | 112 | ## Week 2 Graded Assignments 113 | * Quiz 2: [week-2-quiz](Graded%20Assignment/week2-quiz.md) 114 | * Programming assignment: [notebook](Graded%20Assignment/C1W2_Assignment.ipynb) 115 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/capture-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/capture-1.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/capture-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/capture-2.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/week2-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/week2-quiz/1.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/week2-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/week2-quiz/2.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/week2-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/week2-quiz/3.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/week2-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/week2-quiz/4.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/week2-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/week2-quiz/5.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 2/img/week2-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 2/img/week2-quiz/6.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/Graded Assignment/C1W3_Assignment.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "iQjHqsmTAVLU" 7 | }, 8 | "source": [ 9 | "# Week 3: Improve MNIST with Convolutions\n", 10 | "\n", 11 | "In the videos you looked at how you would improve Fashion MNIST using Convolutions. For this exercise see if you can improve MNIST to 99.5% accuracy or more by adding only a single convolutional layer and a single MaxPooling 2D layer to the model from the assignment of the previous week. \n", 12 | "\n", 13 | "You should stop training once the accuracy goes above this amount. It should happen in less than 10 epochs, so it's ok to hard code the number of epochs for training, but your training must end once it hits the above metric. If it doesn't, then you'll need to redesign your callback.\n", 14 | "\n", 15 | "When 99.5% accuracy has been hit, you should print out the string \"Reached 99.5% accuracy so cancelling training!\"\n" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "metadata": { 22 | "id": "ZpztRwBouwYp" 23 | }, 24 | "outputs": [], 25 | "source": [ 26 | "import os\n", 27 | "import numpy as np\n", 28 | "import tensorflow as tf\n", 29 | "from tensorflow import keras" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "Begin by loading the data. A couple of things to notice:\n", 37 | "\n", 38 | "- The file `mnist.npz` is already included in the current workspace under the `data` directory. By default the `load_data` from Keras accepts a path relative to `~/.keras/datasets` but in this case it is stored somewhere else, as a result of this, you need to specify the full path.\n", 39 | "\n", 40 | "- `load_data` returns the train and test sets in the form of the tuples `(x_train, y_train), (x_test, y_test)` but in this exercise you will be needing only the train set so you can ignore the second tuple." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 2, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# Load the data\n", 50 | "\n", 51 | "# Get current working directory\n", 52 | "current_dir = os.getcwd() \n", 53 | "\n", 54 | "# Append data/mnist.npz to the previous path to get the full path\n", 55 | "data_path = os.path.join(current_dir, \"data/mnist.npz\") \n", 56 | "\n", 57 | "# Get only training set\n", 58 | "(training_images, training_labels), _ = tf.keras.datasets.mnist.load_data(path=data_path) \n" 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "One important step when dealing with image data is to preprocess the data. During the preprocess step you can apply transformations to the dataset that will be fed into your convolutional neural network.\n", 66 | "\n", 67 | "Here you will apply two transformations to the data:\n", 68 | "- Reshape the data so that it has an extra dimension. The reason for this \n", 69 | "is that commonly you will use 3-dimensional arrays (without counting the batch dimension) to represent image data. The third dimension represents the color using RGB values. This data might be in black and white format so the third dimension doesn't really add any additional information for the classification process but it is a good practice regardless.\n", 70 | "\n", 71 | "\n", 72 | "- Normalize the pixel values so that these are values between 0 and 1. You can achieve this by dividing every value in the array by the maximum.\n", 73 | "\n", 74 | "Remember that these tensors are of type `numpy.ndarray` so you can use functions like [reshape](https://numpy.org/doc/stable/reference/generated/numpy.reshape.html) or [divide](https://numpy.org/doc/stable/reference/generated/numpy.divide.html) to complete the `reshape_and_normalize` function below:" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 6, 80 | "metadata": {}, 81 | "outputs": [], 82 | "source": [ 83 | "# GRADED FUNCTION: reshape_and_normalize\n", 84 | "\n", 85 | "def reshape_and_normalize(images):\n", 86 | " \n", 87 | " ### START CODE HERE\n", 88 | "\n", 89 | " # Reshape the images to add an extra dimension\n", 90 | " images = images.reshape(60000, 28, 28, 1)\n", 91 | " \n", 92 | " # Normalize pixel values\n", 93 | " images = images/255\n", 94 | " \n", 95 | " ### END CODE HERE\n", 96 | "\n", 97 | " return images" 98 | ] 99 | }, 100 | { 101 | "cell_type": "markdown", 102 | "metadata": {}, 103 | "source": [ 104 | "Test your function with the next cell:" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 7, 110 | "metadata": {}, 111 | "outputs": [ 112 | { 113 | "name": "stdout", 114 | "output_type": "stream", 115 | "text": [ 116 | "Maximum pixel value after normalization: 1.0\n", 117 | "\n", 118 | "Shape of training set after reshaping: (60000, 28, 28, 1)\n", 119 | "\n", 120 | "Shape of one image after reshaping: (28, 28, 1)\n" 121 | ] 122 | } 123 | ], 124 | "source": [ 125 | "# Reload the images in case you run this cell multiple times\n", 126 | "(training_images, _), _ = tf.keras.datasets.mnist.load_data(path=data_path) \n", 127 | "\n", 128 | "# Apply your function\n", 129 | "training_images = reshape_and_normalize(training_images)\n", 130 | "\n", 131 | "print(f\"Maximum pixel value after normalization: {np.max(training_images)}\\n\")\n", 132 | "print(f\"Shape of training set after reshaping: {training_images.shape}\\n\")\n", 133 | "print(f\"Shape of one image after reshaping: {training_images[0].shape}\")\n" 134 | ] 135 | }, 136 | { 137 | "cell_type": "markdown", 138 | "metadata": {}, 139 | "source": [ 140 | "**Expected Output:**\n", 141 | "```\n", 142 | "Maximum pixel value after normalization: 1.0\n", 143 | "\n", 144 | "Shape of training set after reshaping: (60000, 28, 28, 1)\n", 145 | "\n", 146 | "Shape of one image after reshaping: (28, 28, 1)\n", 147 | "```" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "Now complete the callback that will ensure that training will stop after an accuracy of 99.5% is reached:" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 16, 160 | "metadata": {}, 161 | "outputs": [], 162 | "source": [ 163 | "# GRADED CLASS: myCallback\n", 164 | "### START CODE HERE\n", 165 | "\n", 166 | "# Remember to inherit from the correct class\n", 167 | "class myCallback(tf.keras.callbacks.Callback):\n", 168 | " # Define the method that checks the accuracy at the end of each epoch\n", 169 | " def on_epoch_end(self, epoch, logs=None):\n", 170 | " if logs.get('accuracy') is not None and logs.get('accuracy') >= 0.995:\n", 171 | " print(\"\\nReached 99.5% accuracy so cancelling training!\")\n", 172 | " \n", 173 | " self.model.stop_training = True\n", 174 | "# pass\n", 175 | "\n", 176 | "### END CODE HERE\n", 177 | "\n", 178 | "\n" 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "metadata": {}, 184 | "source": [ 185 | "Finally, complete the `convolutional_model` function below. This function should return your convolutional neural network:" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 14, 191 | "metadata": {}, 192 | "outputs": [], 193 | "source": [ 194 | "# GRADED FUNCTION: convolutional_model\n", 195 | "def convolutional_model():\n", 196 | " ### START CODE HERE\n", 197 | "\n", 198 | " # Define the model, it should have 5 layers:\n", 199 | " # - A Conv2D layer with 32 filters, a kernel_size of 3x3, ReLU activation function\n", 200 | " # and an input shape that matches that of every image in the training set\n", 201 | " # - A MaxPooling2D layer with a pool_size of 2x2\n", 202 | " # - A Flatten layer with no arguments\n", 203 | " # - A Dense layer with 128 units and ReLU activation function\n", 204 | " # - A Dense layer with 10 units and softmax activation function\n", 205 | " model = tf.keras.models.Sequential([ \n", 206 | " tf.keras.layers.Conv2D(32, (3,3), activation='relu', input_shape=(28,28,1)),\n", 207 | " tf.keras.layers.MaxPooling2D(2,2),\n", 208 | " tf.keras.layers.Flatten(),\n", 209 | " tf.keras.layers.Dense(128, activation='relu'),\n", 210 | " tf.keras.layers.Dense(10, activation='softmax')\n", 211 | " ]) \n", 212 | "\n", 213 | " ### END CODE HERE\n", 214 | "\n", 215 | " # Compile the model\n", 216 | " model.compile(optimizer='adam', \n", 217 | " loss='sparse_categorical_crossentropy', \n", 218 | " metrics=['accuracy']) \n", 219 | " \n", 220 | " return model" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": 17, 226 | "metadata": {}, 227 | "outputs": [ 228 | { 229 | "name": "stdout", 230 | "output_type": "stream", 231 | "text": [ 232 | "Epoch 1/10\n", 233 | "1875/1875 [==============================] - 35s 19ms/step - loss: 0.1518 - accuracy: 0.9550\n", 234 | "Epoch 2/10\n", 235 | "1875/1875 [==============================] - 35s 18ms/step - loss: 0.0502 - accuracy: 0.9847\n", 236 | "Epoch 3/10\n", 237 | "1875/1875 [==============================] - 35s 19ms/step - loss: 0.0314 - accuracy: 0.9901\n", 238 | "Epoch 4/10\n", 239 | "1875/1875 [==============================] - 35s 19ms/step - loss: 0.0211 - accuracy: 0.9934\n", 240 | "Epoch 5/10\n", 241 | "1872/1875 [============================>.] - ETA: 0s - loss: 0.0153 - accuracy: 0.9953\n", 242 | "Reached 99.5% accuracy so cancelling training!\n", 243 | "1875/1875 [==============================] - 35s 18ms/step - loss: 0.0152 - accuracy: 0.9953\n" 244 | ] 245 | } 246 | ], 247 | "source": [ 248 | "# Save your untrained model\n", 249 | "model = convolutional_model()\n", 250 | "\n", 251 | "# Instantiate the callback class\n", 252 | "callbacks = myCallback()\n", 253 | "\n", 254 | "# Train your model (this can take up to 5 minutes)\n", 255 | "history = model.fit(training_images, training_labels, epochs=10, callbacks=[callbacks])" 256 | ] 257 | }, 258 | { 259 | "cell_type": "markdown", 260 | "metadata": {}, 261 | "source": [ 262 | "If you see the message that you defined in your callback printed out after less than 10 epochs it means your callback worked as expected. You can also double check by running the following cell:" 263 | ] 264 | }, 265 | { 266 | "cell_type": "code", 267 | "execution_count": 18, 268 | "metadata": {}, 269 | "outputs": [ 270 | { 271 | "name": "stdout", 272 | "output_type": "stream", 273 | "text": [ 274 | "Your model was trained for 5 epochs\n" 275 | ] 276 | } 277 | ], 278 | "source": [ 279 | "print(f\"Your model was trained for {len(history.epoch)} epochs\")" 280 | ] 281 | }, 282 | { 283 | "cell_type": "markdown", 284 | "metadata": {}, 285 | "source": [ 286 | "**Congratulations on finishing this week's assignment!**\n", 287 | "\n", 288 | "You have successfully implemented a CNN to assist you in the image classification task. Nice job!\n", 289 | "\n", 290 | "**Keep it up!**" 291 | ] 292 | } 293 | ], 294 | "metadata": { 295 | "jupytext": { 296 | "main_language": "python" 297 | }, 298 | "kernelspec": { 299 | "display_name": "Python 3", 300 | "language": "python", 301 | "name": "python3" 302 | }, 303 | "language_info": { 304 | "codemirror_mode": { 305 | "name": "ipython", 306 | "version": 3 307 | }, 308 | "file_extension": ".py", 309 | "mimetype": "text/x-python", 310 | "name": "python", 311 | "nbconvert_exporter": "python", 312 | "pygments_lexer": "ipython3", 313 | "version": "3.8.8" 314 | } 315 | }, 316 | "nbformat": 4, 317 | "nbformat_minor": 4 318 | } 319 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/Graded Assignment/week3-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 3 2 | 3 | week-3-quiz 4 | 5 | week-3-quiz 6 | 7 | week-3-quiz 8 | 9 | week-3-quiz 10 | 11 | week-3-quiz 12 | 13 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/README.md: -------------------------------------------------------------------------------- 1 | # Enhancing Vision with Convolutional Neural Networks 2 | 3 | ## What are convolutions and pooling? 4 | * Some convolutions will change the image in such a way that certain features in the image get emphasized 5 | * Pooling is a way of compressing an image 6 | 7 | ```python 8 | model = tf.keras.models.Sequential([ 9 | # input layer in the shape of our data 10 | tf.keras.layers.Flatten(), # input_shape=(28,28) 11 | # hidden layer 12 | tf.keras.layers.Dense(128, activation=tf.nn.relu), 13 | # output layer in the shape of the number categories 14 | tf.keras.layers.Dense(10, activation=tf.nn.softmax) 15 | ]) 16 | ``` 17 | 18 | ## Implementing convolutional layers 19 | 20 | ```python 21 | model = tf.keras..models.Sequential([ 22 | tf.keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(28,28,1)), 23 | tf.keras.layers.MaxPooling2D(2,2), 24 | tf.keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(28,28,1)), 25 | tf.keras.layers.MaxPooling2D(2,2), 26 | tf.keras.layers.Flatten(), 27 | tf.keras.layers.Dense(128, activation='relu'), 28 | tf.keras.layers.Dense(10, activation='softmax') 29 | ]) 30 | ``` 31 | 32 | ### Conv2D 33 | ```python 34 | tf.keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(28,28,1)) 35 | ``` 36 | 37 | ### MaxPooling2D 38 | ```python 39 | tf.keras.layers.MaxPooling2D(2,2) 40 | ``` 41 | 42 | * In max-pooling, we're going to take the maximum value 43 | * It's a two-by-two pool, so for every four pixels, the biggest one will **survive** 44 | 45 | Then, we add another convolutional later and another max-pooling layer and then again, pool to reduce the size. So, by the time the image gets to the flattern to go into the dense layers, it's already **much smaller**. 46 | 47 | ```python 48 | tf.keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(28,28,1)), 49 | tf.keras.layers.MaxPooling2D(2,2), 50 | tf.keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(28,28,1)), 51 | tf.keras.layers.MaxPooling2D(2,2), 52 | ``` 53 | 54 | So, its content has been greatly simplified, the goal being that the convolutions will filter it to the features that determine the output. 55 | 56 | ```python 57 | model.summary() 58 | ``` 59 | 60 | ## Other Notes 61 | **Overfitting** occurs when the network learns the data from the training set really well, but it's too specialised to only that data, and as a result is less effective at interpreting other unseen data. For example, if all your life you only saw red shoes, then when you see a red shoe you would be very good at identifying it. But blue suede shoes might confuse you. 62 | 63 | ## Ungraded Lab 64 | * Lab 1: [Improving accuracy using convolution](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C1/W3/ungraded_labs/C1_W3_Lab_1_improving_accuracy_using_convolutions.ipynb) 65 | * Lab 2: [Exploring Convolutions](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C1/W3/ungraded_labs/C1_W3_Lab_2_exploring_convolutions.ipynb) 66 | 67 | ## Graded Assignments 68 | * Quiz 3: [week-3-quiz](Graded%20Assignment/week3-quiz.md) 69 | * Programming assignment: [notebook](Graded%20Assignment/) 70 | 71 | ## Reference 72 | * [Conv2D](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Conv2D) 73 | * [MaxPooling2D](https://www.tensorflow.org/api_docs/python/tf/keras/layers/MaxPool2D) 74 | * [Convolution Neural Network - Youtube](https://www.youtube.com/playlist?list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF) 75 | * [Image Filtering](https://lodev.org/cgtutor/filtering.html) 76 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/img/capture-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 3/img/capture-1.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/img/capture-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 3/img/capture-2.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/img/week3-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 3/img/week3-quiz/1.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/img/week3-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 3/img/week3-quiz/2.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/img/week3-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 3/img/week3-quiz/3.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/img/week3-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 3/img/week3-quiz/4.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 3/img/week3-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 3/img/week3-quiz/5.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/Graded Assignment/week4-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 4 2 | 3 | week-4-quiz 4 | 5 | week-4-quiz 6 | 7 | week-4-quiz 8 | 9 | week-4-quiz 10 | 11 | week-4-quiz 12 | 13 | week-4-quiz 14 | 15 | week-4-quiz 16 | 17 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/README.md: -------------------------------------------------------------------------------- 1 | # Using Real-world Images 2 | 3 | ## Understanding ImageDataGenerator 4 | ```python 5 | import tensorflow as tf 6 | from tf.keras.preprocessing.image import ImageDataGenerator 7 | 8 | # instantiate an image generator 9 | # pass rescale to normalize the data 10 | train_datagen = ImageDataGenerator(rescale=1./255) 11 | 12 | # point out directory that contains sub-directories that contain images 13 | # the name of sub-directories will be the labels for the images 14 | train_generator = train_datagen.flow_from_directory( 15 | train_dir, 16 | target_size=(300, 300), # input data all has to be the same size 17 | batch_size=128, 18 | class_mode='binary' # binary classifier 19 | ) 20 | 21 | test_datagen = ImageDataGenerator(rescale=1./255) 22 | 23 | validation_generator = test_datagen.flow_from_directory( 24 | validation_dir, 25 | target_size=(300, 300), 26 | batch_size=32, 27 | class_mode='binary' 28 | ) 29 | ``` 30 | 31 | * The images are resized as they are loaded so we don't need to do preprocessing 32 | * Batch size is a term used in machine learning and refers to the number of training examples utilized in one iteration. 33 | 34 | ## Defining a ConvNet to use complex images 35 | Here, we use three sets of convolution pooling layers. 36 | ```python 37 | model = tf.keras.models.Sequential([ 38 | tf.keras.layers.Conv2D(16, (3, 3), activation='relu', input_shape=(300, 300, 3)), 39 | tf.keras.layers.MaxPooling2D(2, 2), 40 | tf.keras.layers.Conv2D(32, (3, 3), activation='relu'), 41 | tf.keras.layers.MaxPooling2D(2, 2), 42 | tf.keras.layers.Conv2D(64, (3, 3), activation='relu'), 43 | tf.keras.layers.MaxPooling2D(2, 2), 44 | tf.keras.layers.Flatten(), 45 | tf.keras.layers.Dense(512, activation='relu'), 46 | tf.keras.layers.Dense(1, activation='sigmoid') 47 | ]) 48 | ``` 49 | 50 | In input shape, because the images are in color we use 3 bytes per pixel for red, green and blue. 51 | ```python 52 | tf.keras.layers.Conv2D(16, (3, 3), activation='relu', input_shape=(300, 300, 3)), 53 | ``` 54 | 55 | For the output layer, we have one neuron for two classes. It because we use different activation. Sigmoid is great for binary classification, where one class will tend towards zero and the other class tending towards one. We could use two neurons here too, and the same softmax function as before, but for binary this is a bit more efficient. 56 | ```python 57 | tf.keras.layers.Dense(1, activation='sigmoid') 58 | ``` 59 | 60 | ## Training The ConvNet 61 | ```python 62 | from tensorflow.keras.optimizers import RMSprop 63 | 64 | model.compile( 65 | loss='binary_crossentropy', 66 | optimizer=RMSprop(lr=0.001), 67 | metrics=['accuracy'] 68 | ) 69 | 70 | history = model.fit( 71 | train_generator, 72 | steps_per_epoch=8, 73 | epochs=15, 74 | validation_data=validation_generator, 75 | validation_steps=8, 76 | verbose=2 77 | ) 78 | ``` 79 | 80 | * There are 1,024 images in the training directory, we're loading them in 128 at a time. In order to load them all, we need to do 8 batches so we set **steps_per_epoch** to cover that. 81 | * We have 256 images from validation_genertaor and we wanted to handle them in batches of 32, so we will do 8 steps. 82 | * Verbose specifies how much to display while training is going on. With verbose set to 2, we'll get a little less animation hiding the epoch progress. 83 | 84 | ```python 85 | import numpy as np 86 | from google.colab import files 87 | from keras.preprocessing import image 88 | 89 | uploaded = files.upload() 90 | 91 | for fn in uploaded.keys(): 92 | 93 | # predicting images 94 | path = '/content/' + fn 95 | img = image.load_img(path, target_size=(300, 300)) 96 | x = image.img_to_array(img) 97 | x = np.expand_dims(x, axis=0) 98 | 99 | images = np.vstack([x]) 100 | classes = model.predict(images, batch_size=10) 101 | print(classes[0]) 102 | if classes[0]>0.5: 103 | print(fn + " is a human") 104 | else: 105 | print(fn + " is a horse") 106 | ``` 107 | 108 | This give us the button that can be pressed to pick one or more images to upload. 109 | ```python 110 | ... 111 | from google.colab import files 112 | 113 | uploaded = files.upload() 114 | 115 | for fn in uploaded.keys(): 116 | ... 117 | ... 118 | ``` 119 | 120 | The loop then iterates through all of the images in that collection. 121 | ```python 122 | img = image.load_img(path, target_size=(300, 300)) 123 | x = image.img_to_array(img) 124 | x = np.expand_dims(x, axis=0) 125 | 126 | images = np.vstack([x]) 127 | ``` 128 | 129 | ## Ungraded Lab 130 | * Lab 1: [Training with ImageDataGenerator](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C1/W4/ungraded_labs/C1_W4_Lab_1_image_generator_no_validation.ipynb) 131 | * Lab 2: [ImageDataGenerator with Validation Set](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C1/W4/ungraded_labs/C1_W4_Lab_2_image_generator_with_validation.ipynb) 132 | 133 | ## References 134 | * [EarlyStopping callback](https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/EarlyStopping) 135 | * [Binary Classification](https://www.youtube.com/watch?v=eqEc66RFY0I&t=6s) 136 | * [Machine Learning Crash Course](https://developers.google.com/machine-learning/crash-course/descending-into-ml/video-lecture) 137 | 138 | 139 | -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/img/week4-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 4/img/week4-quiz/1.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/img/week4-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 4/img/week4-quiz/2.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/img/week4-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 4/img/week4-quiz/3.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/img/week4-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 4/img/week4-quiz/4.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/img/week4-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 4/img/week4-quiz/5.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/img/week4-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 4/img/week4-quiz/6.PNG -------------------------------------------------------------------------------- /1. Introduction to TensorFlow/week 4/img/week4-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/1. Introduction to TensorFlow/week 4/img/week4-quiz/7.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W1.pdf -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W2.pdf -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W3.pdf -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/tf-course2-lecture-notes/C2_W4.pdf -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/Graded Assignments/week1-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 1 2 | 3 | week-1-quiz 4 | 5 | week-1-quiz 6 | 7 | week-1-quiz 8 | 9 | week-1-quiz 10 | 11 | week-1-quiz 12 | 13 | week-1-quiz 14 | 15 | week-1-quiz 16 | 17 | week-1-quiz 18 | -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/1.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/2.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/3.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/4.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/5.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/6.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/7.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-1/img/week1-quiz/8.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/Graded Assignments/week2-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 2 2 | 3 | week-2-quiz 4 | 5 | week-2-quiz 6 | 7 | week-2-quiz 8 | 9 | week-2-quiz 10 | 11 | week-2-quiz 12 | 13 | week-2-quiz 14 | 15 | week-2-quiz 16 | 17 | week-2-quiz 18 | -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/1.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/2.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/3.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/4.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/5.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/6.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/7.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-2/img/week2-quiz/8.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/Graded Assignments/week3-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 3 2 | 3 | week-3-quiz 4 | 5 | week-3-quiz 6 | 7 | week-3-quiz 8 | 9 | week-3-quiz 10 | 11 | week-3-quiz 12 | 13 | week-3-quiz 14 | 15 | week-3-quiz 16 | 17 | week-3-quiz 18 | -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/1.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/2.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/3.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/4.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/5.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/6.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/7.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-3/img/week3-quiz/8.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/Graded Assignments/week4-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 4 2 | 3 | week-4-quiz 4 | 5 | week-4-quiz 6 | 7 | week-4-quiz 8 | 9 | week-4-quiz 10 | 11 | week-4-quiz 12 | 13 | week-4-quiz 14 | 15 | week-4-quiz 16 | 17 | week-4-quiz 18 | -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/1.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/2.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/3.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/4.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/5.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/6.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/7.PNG -------------------------------------------------------------------------------- /2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/2. Convolutional Neural Networks in TensorFlow/week-4/img/week4-quiz/8.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/Graded Assignments/C3W1_Assignment.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "1bed6a4c", 6 | "metadata": {}, 7 | "source": [ 8 | "# Week 1: Explore the BBC News archive\n", 9 | "\n", 10 | "Welcome! In this assignment you will be working with a variation of the [BBC News Classification Dataset](https://www.kaggle.com/c/learn-ai-bbc/overview), which contains 2225 examples of news articles with their respective categories (labels).\n", 11 | "\n", 12 | "Let's get started!" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 4, 18 | "id": "64ace5d7", 19 | "metadata": { 20 | "colab": { 21 | "base_uri": "https://localhost:8080/" 22 | }, 23 | "id": "zrZevCPJ92HG", 24 | "outputId": "4ba10d10-1433-42fc-dc8e-83b297705cfe" 25 | }, 26 | "outputs": [], 27 | "source": [ 28 | "import csv\n", 29 | "from tensorflow.keras.preprocessing.text import Tokenizer\n", 30 | "from tensorflow.keras.preprocessing.sequence import pad_sequences" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "id": "7dcc6e36", 36 | "metadata": {}, 37 | "source": [ 38 | "Begin by looking at the structure of the csv that contains the data:" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 5, 44 | "id": "531133cd", 45 | "metadata": {}, 46 | "outputs": [ 47 | { 48 | "name": "stdout", 49 | "output_type": "stream", 50 | "text": [ 51 | "First line (header) looks like this:\n", 52 | "\n", 53 | "category,text\n", 54 | "\n", 55 | "Each data point looks like this:\n", 56 | "\n", 57 | "tech,tv future in the hands of viewers with home theatre systems plasma high-definition tvs and digital video recorders moving into the living room the way people watch tv will be radically different in five years time. that is according to an expert panel which gathered at the annual consumer electronics show in las vegas to discuss how these new technologies will impact one of our favourite pastimes. with the us leading the trend programmes and other content will be delivered to viewers via home networks through cable satellite telecoms companies and broadband service providers to front rooms and portable devices. one of the most talked-about technologies of ces has been digital and personal video recorders (dvr and pvr). these set-top boxes like the us s tivo and the uk s sky+ system allow people to record store play pause and forward wind tv programmes when they want. essentially the technology allows for much more personalised tv. they are also being built-in to high-definition tv sets which are big business in japan and the us but slower to take off in europe because of the lack of high-definition programming. not only can people forward wind through adverts they can also forget about abiding by network and channel schedules putting together their own a-la-carte entertainment. but some us networks and cable and satellite companies are worried about what it means for them in terms of advertising revenues as well as brand identity and viewer loyalty to channels. although the us leads in this technology at the moment it is also a concern that is being raised in europe particularly with the growing uptake of services like sky+. what happens here today we will see in nine months to a years time in the uk adam hume the bbc broadcast s futurologist told the bbc news website. for the likes of the bbc there are no issues of lost advertising revenue yet. it is a more pressing issue at the moment for commercial uk broadcasters but brand loyalty is important for everyone. we will be talking more about content brands rather than network brands said tim hanlon from brand communications firm starcom mediavest. the reality is that with broadband connections anybody can be the producer of content. he added: the challenge now is that it is hard to promote a programme with so much choice. what this means said stacey jolna senior vice president of tv guide tv group is that the way people find the content they want to watch has to be simplified for tv viewers. it means that networks in us terms or channels could take a leaf out of google s book and be the search engine of the future instead of the scheduler to help people find what they want to watch. this kind of channel model might work for the younger ipod generation which is used to taking control of their gadgets and what they play on them. but it might not suit everyone the panel recognised. older generations are more comfortable with familiar schedules and channel brands because they know what they are getting. they perhaps do not want so much of the choice put into their hands mr hanlon suggested. on the other end you have the kids just out of diapers who are pushing buttons already - everything is possible and available to them said mr hanlon. ultimately the consumer will tell the market they want. of the 50 000 new gadgets and technologies being showcased at ces many of them are about enhancing the tv-watching experience. high-definition tv sets are everywhere and many new models of lcd (liquid crystal display) tvs have been launched with dvr capability built into them instead of being external boxes. one such example launched at the show is humax s 26-inch lcd tv with an 80-hour tivo dvr and dvd recorder. one of the us s biggest satellite tv companies directtv has even launched its own branded dvr at the show with 100-hours of recording capability instant replay and a search function. the set can pause and rewind tv for up to 90 hours. and microsoft chief bill gates announced in his pre-show keynote speech a partnership with tivo called tivotogo which means people can play recorded programmes on windows pcs and mobile devices. all these reflect the increasing trend of freeing up multimedia so that people can watch what they want when they want.\n", 58 | "\n" 59 | ] 60 | } 61 | ], 62 | "source": [ 63 | "with open(\"./bbc-text.csv\", 'r') as csvfile:\n", 64 | " print(f\"First line (header) looks like this:\\n\\n{csvfile.readline()}\")\n", 65 | " print(f\"Each data point looks like this:\\n\\n{csvfile.readline()}\") " 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "id": "67a2c94f", 71 | "metadata": {}, 72 | "source": [ 73 | "As you can see, each data point is composed of the category of the news article followed by a comma and then the actual text of the article." 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "id": "3c61761e", 79 | "metadata": {}, 80 | "source": [ 81 | "## Removing Stopwords\n", 82 | "\n", 83 | "One important step when working with text data is to remove the **stopwords** from it. These are the most common words in the language and they rarely provide useful information for the classification process.\n", 84 | "\n", 85 | "Complete the `remove_stopwords` below. This function should receive a string and return another string that excludes all of the stopwords provided." 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 6, 91 | "id": "3336c693", 92 | "metadata": {}, 93 | "outputs": [], 94 | "source": [ 95 | "# GRADED FUNCTION: remove_stopwords\n", 96 | "def remove_stopwords(sentence):\n", 97 | " # List of stopwords\n", 98 | " stopwords = [\"a\", \"about\", \"above\", \"after\", \"again\", \"against\", \"all\", \"am\", \"an\", \"and\", \"any\", \"are\", \"as\", \"at\", \"be\", \"because\", \"been\", \"before\", \"being\", \"below\", \"between\", \"both\", \"but\", \"by\", \"could\", \"did\", \"do\", \"does\", \"doing\", \"down\", \"during\", \"each\", \"few\", \"for\", \"from\", \"further\", \"had\", \"has\", \"have\", \"having\", \"he\", \"he'd\", \"he'll\", \"he's\", \"her\", \"here\", \"here's\", \"hers\", \"herself\", \"him\", \"himself\", \"his\", \"how\", \"how's\", \"i\", \"i'd\", \"i'll\", \"i'm\", \"i've\", \"if\", \"in\", \"into\", \"is\", \"it\", \"it's\", \"its\", \"itself\", \"let's\", \"me\", \"more\", \"most\", \"my\", \"myself\", \"nor\", \"of\", \"on\", \"once\", \"only\", \"or\", \"other\", \"ought\", \"our\", \"ours\", \"ourselves\", \"out\", \"over\", \"own\", \"same\", \"she\", \"she'd\", \"she'll\", \"she's\", \"should\", \"so\", \"some\", \"such\", \"than\", \"that\", \"that's\", \"the\", \"their\", \"theirs\", \"them\", \"themselves\", \"then\", \"there\", \"there's\", \"these\", \"they\", \"they'd\", \"they'll\", \"they're\", \"they've\", \"this\", \"those\", \"through\", \"to\", \"too\", \"under\", \"until\", \"up\", \"very\", \"was\", \"we\", \"we'd\", \"we'll\", \"we're\", \"we've\", \"were\", \"what\", \"what's\", \"when\", \"when's\", \"where\", \"where's\", \"which\", \"while\", \"who\", \"who's\", \"whom\", \"why\", \"why's\", \"with\", \"would\", \"you\", \"you'd\", \"you'll\", \"you're\", \"you've\", \"your\", \"yours\", \"yourself\", \"yourselves\" ]\n", 99 | " \n", 100 | " # Sentence converted to lowercase-only\n", 101 | " sentence = sentence.lower()\n", 102 | " \n", 103 | " ### START CODE HERE\n", 104 | " sentence = sentence.split()\n", 105 | " temp_sentence = []\n", 106 | " for word in sentence:\n", 107 | " if word not in stopwords:\n", 108 | " temp_sentence.append(word)\n", 109 | " \n", 110 | " sentence = \" \".join(temp_sentence)\n", 111 | " \n", 112 | "# print(temp_sentence)\n", 113 | " ### END CODE HERE\n", 114 | " return sentence" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 7, 120 | "id": "857d2bce", 121 | "metadata": {}, 122 | "outputs": [ 123 | { 124 | "data": { 125 | "text/plain": [ 126 | "'go store get snack'" 127 | ] 128 | }, 129 | "execution_count": 7, 130 | "metadata": {}, 131 | "output_type": "execute_result" 132 | } 133 | ], 134 | "source": [ 135 | "# Test your function\n", 136 | "remove_stopwords(\"I am about to go to the store and get any snack\")" 137 | ] 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "id": "69317cd6", 142 | "metadata": {}, 143 | "source": [ 144 | "***Expected Output:***\n", 145 | "```\n", 146 | "'go store get snack'\n", 147 | "\n", 148 | "```" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "id": "e8c5c829", 154 | "metadata": {}, 155 | "source": [ 156 | "## Reading the raw data\n", 157 | "\n", 158 | "Now you need to read the data from the csv file. To do so, complete the `parse_data_from_file` function.\n", 159 | "\n", 160 | "A couple of things to note:\n", 161 | "- You should omit the first line as it contains the headers and not data points.\n", 162 | "- There is no need to save the data points as numpy arrays, regular lists is fine.\n", 163 | "- To read from csv files use [`csv.reader`](https://docs.python.org/3/library/csv.html#csv.reader) by passing the appropriate arguments.\n", 164 | "- `csv.reader` returns an iterable that returns each row in every iteration. So the label can be accessed via row[0] and the text via row[1].\n", 165 | "- Use the `remove_stopwords` function in each sentence." 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 8, 171 | "id": "c9ae1cd1", 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "def parse_data_from_file(filename):\n", 176 | " sentences = []\n", 177 | " labels = []\n", 178 | " with open(filename, 'r') as csvfile:\n", 179 | " ### START CODE HERE\n", 180 | " reader = csv.reader(csvfile, delimiter=',')\n", 181 | " next(reader)\n", 182 | " for row in reader:\n", 183 | " labels.append(row[0])\n", 184 | " sentence = row[1]\n", 185 | " sentences.append(remove_stopwords(sentence))\n", 186 | " \n", 187 | " ### END CODE HERE\n", 188 | " return sentences, labels" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 9, 194 | "id": "6a4bb82b", 195 | "metadata": {}, 196 | "outputs": [ 197 | { 198 | "name": "stdout", 199 | "output_type": "stream", 200 | "text": [ 201 | "There are 2225 sentences in the dataset.\n", 202 | "\n", 203 | "First sentence has 436 words (after removing stopwords).\n", 204 | "\n", 205 | "There are 2225 labels in the dataset.\n", 206 | "\n", 207 | "The first 5 labels are ['tech', 'business', 'sport', 'sport', 'entertainment']\n" 208 | ] 209 | } 210 | ], 211 | "source": [ 212 | "# Test your function\n", 213 | "sentences, labels = parse_data_from_file(\"./bbc-text.csv\")\n", 214 | "\n", 215 | "print(f\"There are {len(sentences)} sentences in the dataset.\\n\")\n", 216 | "print(f\"First sentence has {len(sentences[0].split())} words (after removing stopwords).\\n\")\n", 217 | "print(f\"There are {len(labels)} labels in the dataset.\\n\")\n", 218 | "print(f\"The first 5 labels are {labels[:5]}\")" 219 | ] 220 | }, 221 | { 222 | "cell_type": "markdown", 223 | "id": "1e18ed03", 224 | "metadata": {}, 225 | "source": [ 226 | "***Expected Output:***\n", 227 | "```\n", 228 | "There are 2225 sentences in the dataset.\n", 229 | "\n", 230 | "First sentence has 436 words (after removing stopwords).\n", 231 | "\n", 232 | "There are 2225 labels in the dataset.\n", 233 | "\n", 234 | "The first 5 labels are ['tech', 'business', 'sport', 'sport', 'entertainment']\n", 235 | "\n", 236 | "```" 237 | ] 238 | }, 239 | { 240 | "cell_type": "markdown", 241 | "id": "899468d5", 242 | "metadata": {}, 243 | "source": [ 244 | "## Using the Tokenizer\n", 245 | "\n", 246 | "Now it is time to tokenize the sentences of the dataset. \n", 247 | "\n", 248 | "Complete the `fit_tokenizer` below. \n", 249 | "\n", 250 | "This function should receive the list of sentences as input and return a [Tokenizer](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer) that has been fitted to those sentences. You should also define the \"Out of Vocabulary\" token as ``." 251 | ] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": 14, 256 | "id": "7becc50a", 257 | "metadata": {}, 258 | "outputs": [], 259 | "source": [ 260 | "def fit_tokenizer(sentences):\n", 261 | " ### START CODE HERE\n", 262 | " # Instantiate the Tokenizer class by passing in the oov_token argument\n", 263 | " tokenizer = Tokenizer(oov_token=\"\")\n", 264 | " # Fit on the sentences\n", 265 | " tokenizer.fit_on_texts(sentences)\n", 266 | " \n", 267 | " ### END CODE HERE\n", 268 | " return tokenizer" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": 15, 274 | "id": "b9064ab4", 275 | "metadata": {}, 276 | "outputs": [ 277 | { 278 | "name": "stdout", 279 | "output_type": "stream", 280 | "text": [ 281 | "Vocabulary contains 29714 words\n", 282 | "\n", 283 | " token included in vocabulary\n" 284 | ] 285 | } 286 | ], 287 | "source": [ 288 | "tokenizer = fit_tokenizer(sentences)\n", 289 | "word_index = tokenizer.word_index\n", 290 | "\n", 291 | "print(f\"Vocabulary contains {len(word_index)} words\\n\")\n", 292 | "print(\" token included in vocabulary\" if \"\" in word_index else \" token NOT included in vocabulary\")" 293 | ] 294 | }, 295 | { 296 | "cell_type": "markdown", 297 | "id": "75a00cb3", 298 | "metadata": {}, 299 | "source": [ 300 | "***Expected Output:***\n", 301 | "```\n", 302 | "Vocabulary contains 29714 words\n", 303 | "\n", 304 | " token included in vocabulary\n", 305 | "\n", 306 | "```" 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": 16, 312 | "id": "eb9ab613", 313 | "metadata": {}, 314 | "outputs": [], 315 | "source": [ 316 | "def get_padded_sequences(tokenizer, sentences):\n", 317 | " \n", 318 | " ### START CODE HERE\n", 319 | " # Convert sentences to sequences\n", 320 | " sequences = tokenizer.texts_to_sequences(sentences)\n", 321 | " \n", 322 | " # Pad the sequences using the post padding strategy\n", 323 | " padded_sequences = pad_sequences(sequences, padding='post')\n", 324 | " ### END CODE HERE\n", 325 | " \n", 326 | " return padded_sequences" 327 | ] 328 | }, 329 | { 330 | "cell_type": "code", 331 | "execution_count": 17, 332 | "id": "4d966404", 333 | "metadata": {}, 334 | "outputs": [ 335 | { 336 | "name": "stdout", 337 | "output_type": "stream", 338 | "text": [ 339 | "First padded sequence looks like this: \n", 340 | "\n", 341 | "[ 96 176 1157 ... 0 0 0]\n", 342 | "\n", 343 | "Numpy array of all sequences has shape: (2225, 2438)\n", 344 | "\n", 345 | "This means there are 2225 sequences in total and each one has a size of 2438\n" 346 | ] 347 | } 348 | ], 349 | "source": [ 350 | "padded_sequences = get_padded_sequences(tokenizer, sentences)\n", 351 | "print(f\"First padded sequence looks like this: \\n\\n{padded_sequences[0]}\\n\")\n", 352 | "print(f\"Numpy array of all sequences has shape: {padded_sequences.shape}\\n\")\n", 353 | "print(f\"This means there are {padded_sequences.shape[0]} sequences in total and each one has a size of {padded_sequences.shape[1]}\")" 354 | ] 355 | }, 356 | { 357 | "cell_type": "markdown", 358 | "id": "6caae3d6", 359 | "metadata": {}, 360 | "source": [ 361 | "***Expected Output:***\n", 362 | "```\n", 363 | "First padded sequence looks like this: \n", 364 | "\n", 365 | "[ 96 176 1157 ... 0 0 0]\n", 366 | "\n", 367 | "Numpy array of all sequences has shape: (2225, 2438)\n", 368 | "\n", 369 | "This means there are 2225 sequences in total and each one has a size of 2438\n", 370 | "\n", 371 | "```" 372 | ] 373 | }, 374 | { 375 | "cell_type": "code", 376 | "execution_count": 18, 377 | "id": "5b9b1225", 378 | "metadata": {}, 379 | "outputs": [], 380 | "source": [ 381 | "def tokenize_labels(labels):\n", 382 | " ### START CODE HERE\n", 383 | " \n", 384 | " # Instantiate the Tokenizer class\n", 385 | " # No need to pass additional arguments since you will be tokenizing the labels\n", 386 | " label_tokenizer = Tokenizer()\n", 387 | " \n", 388 | " # Fit the tokenizer to the labels\n", 389 | " label_tokenizer.fit_on_texts(labels)\n", 390 | " \n", 391 | " # Save the word index\n", 392 | " label_word_index = label_tokenizer.word_index\n", 393 | " \n", 394 | " # Save the sequences\n", 395 | " label_sequences = label_tokenizer.texts_to_sequences(labels)\n", 396 | "\n", 397 | " ### END CODE HERE\n", 398 | " \n", 399 | " return label_sequences, label_word_index" 400 | ] 401 | }, 402 | { 403 | "cell_type": "code", 404 | "execution_count": 19, 405 | "id": "493fb321", 406 | "metadata": {}, 407 | "outputs": [ 408 | { 409 | "name": "stdout", 410 | "output_type": "stream", 411 | "text": [ 412 | "Vocabulary of labels looks like this {'sport': 1, 'business': 2, 'politics': 3, 'tech': 4, 'entertainment': 5}\n", 413 | "\n", 414 | "First ten sequences [[4], [2], [1], [1], [5], [3], [3], [1], [1], [5]]\n", 415 | "\n" 416 | ] 417 | } 418 | ], 419 | "source": [ 420 | "label_sequences, label_word_index = tokenize_labels(labels)\n", 421 | "print(f\"Vocabulary of labels looks like this {label_word_index}\\n\")\n", 422 | "print(f\"First ten sequences {label_sequences[:10]}\\n\")" 423 | ] 424 | }, 425 | { 426 | "cell_type": "markdown", 427 | "id": "pressed-surge", 428 | "metadata": {}, 429 | "source": [ 430 | "***Expected Output:***\n", 431 | "```\n", 432 | "Vocabulary of labels looks like this {'sport': 1, 'business': 2, 'politics': 3, 'tech': 4, 'entertainment': 5}\n", 433 | "\n", 434 | "First ten sequences [[4], [2], [1], [1], [5], [3], [3], [1], [1], [5]]\n", 435 | "\n", 436 | "```" 437 | ] 438 | }, 439 | { 440 | "cell_type": "markdown", 441 | "id": "1a4982ac", 442 | "metadata": { 443 | "id": "6rITvNKqT-51" 444 | }, 445 | "source": [ 446 | "**Congratulations on finishing this week's assignment!**\n", 447 | "\n", 448 | "You have successfully implemented functions to process various text data processing ranging from pre-processing, reading from raw files and tokenizing text.\n", 449 | "\n", 450 | "**Keep it up!**" 451 | ] 452 | } 453 | ], 454 | "metadata": { 455 | "kernelspec": { 456 | "display_name": "Python 3", 457 | "language": "python", 458 | "name": "python3" 459 | }, 460 | "language_info": { 461 | "codemirror_mode": { 462 | "name": "ipython", 463 | "version": 3 464 | }, 465 | "file_extension": ".py", 466 | "mimetype": "text/x-python", 467 | "name": "python", 468 | "nbconvert_exporter": "python", 469 | "pygments_lexer": "ipython3", 470 | "version": "3.8.8" 471 | } 472 | }, 473 | "nbformat": 4, 474 | "nbformat_minor": 5 475 | } 476 | -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/Graded Assignments/week1-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 1 2 | 3 | week-1-quiz 4 | 5 | week-1-quiz 6 | 7 | week-1-quiz 8 | 9 | week-1-quiz 10 | 11 | week-1-quiz 12 | 13 | week-1-quiz 14 | 15 | week-1-quiz 16 | 17 | week-1-quiz -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/README.md: -------------------------------------------------------------------------------- 1 | # Sentiment in Text 2 | 3 | Unlike images, which come in these regular shaped tensors of pixel intensity values, Text is messier, there are long sentences, there are short sentences. We're going to take a look at what it takes for you to process text because neural networks generally deal in numbers. 4 | 5 | ## Introduction 6 | In the earlier, we have learned about: 7 | * Neural networks and how they can match patterns to perform classifications. 8 | * How to make that a little smarter for images using convolutions to identify the features in the images and classify based on those instead of just matching on raw pixels 9 | 10 | In this course, we'll focus on text and how we can build classifier is based on text models. We'll start by looking at sentiment in text, and learn how to build models that understand text that are trained on labeled text, and then can then classify new text based on what they've seen. 11 | 12 | ## Word Based Encodings 13 | A common simple character encoding is ASCII, the American Standard Code for Information Interchange. But the problem with this of course, is that the semantics of the word aren't encoded in the letters. 14 | 15 | ## Using APIs 16 | ```python 17 | import tensorflow as tf 18 | from tf import keras 19 | from tf.keras.preprocessing.text import Tokenizer 20 | 21 | sentences = [ 22 | 'I love my dog', 23 | 'I love my cat', 24 | 'You love my dog' 25 | ] 26 | 27 | # num_words, tokenizer take the top 100 words by volume and encode those 28 | tokenizer = Tokenizer(num_words = 100) 29 | 30 | # take the data and encode it 31 | # generate indices for each word in the corpus 32 | tokenizer.fit_on_texts(sentences) 33 | 34 | # word_index retrun dictionary containing key value pairs 35 | # key is the word and value is token for the word 36 | word_index = tokenizer.word_index 37 | print(word_index) 38 | # print(f'Found {word_index} uniq words') 39 | ``` 40 | 41 | By default, Tokenizer skips all punctuations and words are converted to lower case 42 | 43 | ## Text to Sequence 44 | text to sequence is about turn sentences into lists of values based on tokens made before. 45 | 46 | ```python 47 | import tensorflow as tf 48 | from tf import keras 49 | from tf.keras.preprocessing.text import Tokenizer 50 | 51 | sentences = [ 52 | 'I love my dog', 53 | 'I love my cat', 54 | 'You love my dog', 55 | 'Do you think my dog is amazing?' 56 | ] 57 | 58 | tokenizer = Tokenizer(num_words = 100, oov_token="") 59 | tokenizer.fit_on_texts(sentences) 60 | word_index = tokenizer.word_index 61 | 62 | sequences = tokenizer.texts_to_sequences(sentences) 63 | 64 | print(word_index) 65 | print(sequences) 66 | ``` 67 | 68 | Output: 69 | sequences 70 | 71 | ## Looking more at the Tokenizer 72 | We really need a lot of training data to get a broad vocabulary. In many cases, it's a good idea to instead of just ignoring unseen words, to put a special value in when an unseen word is encountered. We will use OOV (out of vocabulary) token. 73 | 74 | ```python 75 | import tensorflow as tf 76 | from tf import keras 77 | from tf.keras.preprocessing.text import Tokenizer 78 | 79 | sentences = [ 80 | 'I love my dog', 81 | 'I love my cat', 82 | 'You love my dog', 83 | 'Do you think my dog is amazing?' 84 | ] 85 | 86 | tokenizer = Tokenizer(num_words = 100, oov_token="") 87 | tokenizer.fit_on_texts(sentences) 88 | word_index = tokenizer.word_index 89 | 90 | sequences = tokenizer.texts_to_sequences(sentences) 91 | 92 | print(word_index) 93 | print(sequences) 94 | ``` 95 | 96 | Output: 97 | oov 98 | 99 | ## Padding 100 | Working with texts, we needed to have some level of uniformity of size. So, we will use padding. 101 | 102 | ```python 103 | import tensorflow as tf 104 | from tf import keras 105 | from tf.keras.preprocessing.text import Tokenizer 106 | from tf.keras.preprocessing.sequence import pad_sequences 107 | 108 | sentences = [ 109 | 'I love my dog', 110 | 'I love my cat', 111 | 'You love my dog', 112 | 'Do you think my dog is amazing?' 113 | ] 114 | 115 | tokenizer = Tokenizer(num_words = 100, oov_token="") 116 | tokenizer.fit_on_texts(sentences) 117 | word_index = tokenizer.word_index 118 | 119 | sequences = tokenizer.texts_to_sequences(sentences) 120 | 121 | padded = pad_sequences(sequences) 122 | 123 | print(word_index) 124 | print(sequences) 125 | print(padded) 126 | ``` 127 | 128 | Output: 129 | padding 130 | 131 | Padding parameters 132 | ```python 133 | padded = pad_sequences( 134 | sequences, 135 | padding='post', 136 | truncating='post', 137 | maxlen=5) 138 | ``` 139 | 140 | * ``padding='post'``, put padding after the sentence 141 | * ``truncating='post'``, lose the beginning of the sentence 142 | * ``maxlen=5``, maximum of 5 words 143 | 144 | When we're training a neural network, we do want to have all the data to be the same size, this is the use of pad_sequences. 145 | 146 | ## Ungraded Labs 147 | * Lab 1: [Tokenizer Basics](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W1/ungraded_labs/C3_W1_Lab_1_tokenize_basic.ipynb) 148 | * Lab 2: [Generating Sequences and Padding](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W1/ungraded_labs/C3_W1_Lab_2_sequences_basic.ipynb) 149 | * Lab 3: [Tokenizing the Sarcasm Dataset](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W1/ungraded_labs/C3_W1_Lab_3_sarcasm.ipynb) 150 | 151 | ## References 152 | * [Text Tokenization](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer#arguments) 153 | * [Assignments](https://charon.me/posts/keras/keras3/) -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/oov.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/oov.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/padding.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/padding.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/practice-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/practice-1.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/sarcastic-dataset.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/sarcastic-dataset.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/sequences.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/sequences.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/1.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/2.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/3.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/4.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/5.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/6.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/7.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-1/img/week1-quiz/8.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-1/practice.md: -------------------------------------------------------------------------------- 1 | # Practice 2 | Dataset: [Sarcsm in News Headlines Dataset by Rishabh Misra](https://www.kaggle.com/datasets/rmisra/news-headlines-dataset-for-sarcasm-detection) 3 | 4 | There are three elements in it: 5 | * Sarcastic as label 6 | ``` 7 | is_sarcastic: 1 if the record is sarcastic 8 | otherwise 0 9 | ``` 10 | * Headline which is just plain text, the headline of the news article 11 | * Article link, link to the original news article 12 | 13 | sarcastic-dataset 14 | 15 | ```python 16 | import json 17 | 18 | with.open("sarcasm.json", 'r') as f: 19 | datastore = json.load(f) 20 | 21 | sentences = [] 22 | labels = [] 23 | urls = [] 24 | 25 | for item in datastore: 26 | sentences.append(item['headline']) 27 | labels.append(item['is_sarcastic']) 28 | urls.append(item['article_link']) 29 | ``` 30 | 31 | ## Working with Tokenizer 32 | 33 | ```python 34 | from tensorflow.keras.processing.text import Tokenizer 35 | from tensorflow.keras.processing.text import pad_sequences 36 | 37 | tokenizer = Tokenizer(oov_token="") 38 | # generate word index 39 | tokenizer.fit_on_texts(sentence) 40 | # generate key value 41 | word_index = tokenizer.word_index 42 | 43 | sequences = tokenizer.texts_to_sequences(sentences) 44 | padded = pad_sequences(sequences, padding='post') 45 | print(padded[0]) 46 | print(padded.shape) 47 | ``` 48 | 49 | Output: 50 | practice-1 -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/Graded Assignments/Tensorflow Embedding Projector/meta.tsv: -------------------------------------------------------------------------------- 1 | 2 | s 3 | said 4 | will 5 | not 6 | mr 7 | year 8 | also 9 | people 10 | new 11 | us 12 | one 13 | can 14 | last 15 | t 16 | first 17 | time 18 | two 19 | government 20 | world 21 | now 22 | uk 23 | best 24 | years 25 | no 26 | make 27 | just 28 | film 29 | told 30 | made 31 | get 32 | music 33 | game 34 | like 35 | back 36 | many 37 | 000 38 | labour 39 | three 40 | well 41 | 1 42 | next 43 | bbc 44 | take 45 | set 46 | number 47 | added 48 | way 49 | market 50 | 2 51 | company 52 | may 53 | says 54 | election 55 | home 56 | off 57 | party 58 | good 59 | going 60 | much 61 | work 62 | 2004 63 | still 64 | win 65 | show 66 | think 67 | games 68 | go 69 | top 70 | second 71 | won 72 | million 73 | 6 74 | england 75 | firm 76 | since 77 | week 78 | say 79 | play 80 | part 81 | public 82 | use 83 | blair 84 | 3 85 | want 86 | minister 87 | however 88 | 10 89 | country 90 | technology 91 | see 92 | 4 93 | five 94 | british 95 | news 96 | european 97 | high 98 | group 99 | tv 100 | used 101 | end 102 | expected 103 | even 104 | players 105 | m 106 | brown 107 | 5 108 | six 109 | old 110 | net 111 | already 112 | four 113 | plans 114 | put 115 | come 116 | half 117 | london 118 | sales 119 | growth 120 | don 121 | long 122 | economy 123 | service 124 | right 125 | months 126 | chief 127 | day 128 | mobile 129 | former 130 | money 131 | britain 132 | director 133 | tax 134 | services 135 | 2005 136 | deal 137 | need 138 | help 139 | digital 140 | according 141 | big 142 | industry 143 | place 144 | companies 145 | users 146 | system 147 | business 148 | including 149 | team 150 | final 151 | based 152 | hit 153 | record 154 | report 155 | third 156 | called 157 | really 158 | international 159 | month 160 | move 161 | wales 162 | europe 163 | another 164 | 7 165 | life 166 | around 167 | economic 168 | start 169 | great 170 | future 171 | 2003 172 | firms 173 | came 174 | france 175 | open 176 | got 177 | spokesman 178 | software 179 | re 180 | without 181 | general 182 | club 183 | took 184 | up 185 | ireland 186 | video 187 | howard 188 | know 189 | united 190 | online 191 | bank 192 | phone 193 | china 194 | far 195 | state 196 | campaign 197 | side 198 | law 199 | radio 200 | better 201 | court 202 | making 203 | decision 204 | executive 205 | real 206 | media 207 | offer 208 | give 209 | computer 210 | found 211 | action 212 | able 213 | president 214 | information 215 | despite 216 | office 217 | star 218 | lot 219 | o 220 | national 221 | line 222 | countries 223 | likely 224 | using 225 | away 226 | player 227 | internet 228 | saying 229 | it 230 | every 231 | given 232 | security 233 | become 234 | left 235 | awards 236 | figures 237 | anti 238 | nations 239 | run 240 | eu 241 | 20 242 | cost 243 | ve 244 | prime 245 | role 246 | seen 247 | playing 248 | biggest 249 | man 250 | january 251 | data 252 | bill 253 | whether 254 | played 255 | later 256 | foreign 257 | although 258 | cup 259 | hard 260 | award 261 | rise 262 | broadband 263 | times 264 | match 265 | chancellor 266 | oil 267 | pay 268 | lost 269 | taking 270 | house 271 | due 272 | past 273 | interest 274 | early 275 | never 276 | lord 277 | leader 278 | support 279 | case 280 | prices 281 | look 282 | microsoft 283 | shares 284 | michael 285 | legal 286 | analysts 287 | control 288 | believe 289 | december 290 | less 291 | days 292 | cut 293 | recent 294 | season 295 | little 296 | children 297 | e 298 | ahead 299 | earlier 300 | increase 301 | thought 302 | free 303 | john 304 | face 305 | research 306 | scotland 307 | important 308 | something 309 | current 310 | strong 311 | went 312 | issue 313 | secretary 314 | south 315 | local 316 | tory 317 | rights 318 | working 319 | power 320 | budget 321 | financial 322 | spending 323 | 12 324 | quarter 325 | access 326 | currently 327 | held 328 | major 329 | chance 330 | change 331 | trade 332 | films 333 | find 334 | looking 335 | try 336 | following 337 | sunday 338 | 0 339 | full 340 | tories 341 | yet 342 | return 343 | series 344 | latest 345 | meeting 346 | share 347 | different 348 | website 349 | david 350 | winning 351 | almost 352 | injury 353 | sale 354 | must 355 | lead 356 | enough 357 | personal 358 | programme 359 | might 360 | police 361 | low 362 | band 363 | problems 364 | ever 365 | keep 366 | rate 367 | announced 368 | always 369 | key 370 | coach 371 | williams 372 | sold 373 | across 374 | performance 375 | dollar 376 | 11 377 | among 378 | behind 379 | ago 380 | list 381 | 8 382 | 9 383 | clear 384 | getting 385 | political 386 | victory 387 | 25 388 | mark 389 | chairman 390 | include 391 | women 392 | demand 393 | 30 394 | statement 395 | ms 396 | march 397 | february 398 | things 399 | term 400 | rather 401 | jobs 402 | minutes 403 | tuesday 404 | american 405 | chelsea 406 | claims 407 | done 408 | content 409 | continue 410 | point 411 | job 412 | manager 413 | means 414 | head 415 | problem 416 | title 417 | actor 418 | coming 419 | huge 420 | price 421 | asked 422 | released 423 | taken 424 | mail 425 | men 426 | union 427 | members 428 | india 429 | allow 430 | weeks 431 | wednesday 432 | act 433 | japan 434 | rugby 435 | plan 436 | tony 437 | global 438 | investment 439 | least 440 | result 441 | apple 442 | 50 443 | young 444 | network 445 | today 446 | within 447 | costs 448 | fans 449 | forward 450 | d 451 | bid 452 | main 453 | french 454 | possible 455 | production 456 | needed 457 | running 458 | site 459 | beat 460 | november 461 | 18 462 | small 463 | war 464 | council 465 | consumer 466 | available 467 | saturday 468 | form 469 | warned 470 | thing 471 | monday 472 | cash 473 | vote 474 | hold 475 | several 476 | known 477 | wanted 478 | mps 479 | song 480 | pc 481 | issues 482 | total 483 | committee 484 | friday 485 | 15 486 | level 487 | live 488 | football 489 | though 490 | evidence 491 | policy 492 | prize 493 | version 494 | success 495 | led 496 | league 497 | search 498 | trying 499 | 2001 500 | human 501 | calls 502 | previous 503 | buy 504 | sir 505 | recently 506 | saw 507 | web 508 | sony 509 | rates 510 | family 511 | parties 512 | aid 513 | single 514 | album 515 | centre 516 | eight 517 | name 518 | customers 519 | rules 520 | meet 521 | close 522 | development 523 | ministers 524 | others 525 | thursday 526 | health 527 | book 528 | competition 529 | stock 530 | agreed 531 | call 532 | phones 533 | 100 534 | difficult 535 | short 536 | let 537 | race 538 | yukos 539 | consumers 540 | popular 541 | comes 542 | co 543 | fact 544 | charles 545 | event 546 | hope 547 | failed 548 | fourth 549 | higher 550 | showed 551 | networks 552 | debt 553 | board 554 | actress 555 | commission 556 | trial 557 | city 558 | wants 559 | october 560 | italy 561 | choice 562 | york 563 | lib 564 | reported 565 | feel 566 | nothing 567 | conference 568 | project 569 | career 570 | bt 571 | sites 572 | boss 573 | didn 574 | points 575 | liberal 576 | late 577 | sure 578 | liverpool 579 | festival 580 | reports 581 | black 582 | received 583 | cannot 584 | annual 585 | together 586 | instead 587 | claim 588 | shows 589 | gaming 590 | tour 591 | dvd 592 | break 593 | launch 594 | claimed 595 | paid 596 | mean 597 | on 598 | devices 599 | christmas 600 | jones 601 | movie 602 | boost 603 | goal 604 | virus 605 | growing 606 | stage 607 | release 608 | age 609 | largest 610 | september 611 | large 612 | leading 613 | summer 614 | champion 615 | 2002 616 | involved 617 | position 618 | arsenal 619 | west 620 | denied 621 | changes 622 | russian 623 | out 624 | believes 625 | manchester 626 | profits 627 | to 628 | paul 629 | singer 630 | iraq 631 | in 632 | needs 633 | fall 634 | television 635 | products 636 | idea 637 | stop 638 | them 639 | gordon 640 | parliament 641 | 17 642 | australian 643 | pressure 644 | sport 645 | love 646 | germany 647 | africa 648 | started 649 | create 650 | order 651 | scottish 652 | talks 653 | giant 654 | potential 655 | 13 656 | german 657 | test 658 | pre 659 | weekend 660 | 16 661 | quite 662 | round 663 | opening 664 | whole 665 | squad 666 | martin 667 | association 668 | special 669 | senior 670 | launched 671 | box 672 | chart 673 | oscar 674 | seven 675 | street 676 | rose 677 | value 678 | conservative 679 | sent 680 | stars 681 | ball 682 | car 683 | v 684 | anything 685 | grand 686 | groups 687 | hours 688 | accused 689 | 40 690 | stand 691 | remain 692 | 2000 693 | cards 694 | either 695 | hopes 696 | ensure 697 | olympic 698 | simply 699 | robinson 700 | fight 701 | similar 702 | press 703 | smith 704 | range 705 | irish 706 | drive 707 | 2006 708 | exchange 709 | rock 710 | official 711 | 24 712 | 14 713 | results 714 | bit 715 | appeal 716 | turn 717 | dr 718 | provide 719 | ukip 720 | immigration 721 | that 722 | period 723 | makes 724 | target 725 | helped 726 | investors 727 | standard 728 | wrong 729 | sell 730 | attack 731 | commons 732 | fell 733 | independent 734 | tsunami 735 | particularly 736 | meanwhile 737 | comedy 738 | proposals 739 | education 740 | average 741 | energy 742 | lords 743 | ban 744 | gave 745 | impact 746 | via 747 | moment 748 | compared 749 | school 750 | happy 751 | card 752 | forced 753 | ll 754 | charge 755 | attacks 756 | spam 757 | generation 758 | force 759 | brought 760 | amount 761 | private 762 | community 763 | sector 764 | per 765 | bring 766 | fraud 767 | became 768 | fund 769 | euros 770 | extra 771 | systems 772 | everyone 773 | speech 774 | admitted 775 | poll 776 | history 777 | message 778 | numbers 779 | included 780 | widely 781 | gadget 782 | entertainment 783 | windows 784 | debate 785 | speaking 786 | selling 787 | hand 788 | bad 789 | department 790 | laws 791 | workers 792 | date 793 | australia 794 | charges 795 | markets 796 | night 797 | audience 798 | named 799 | russia 800 | comments 801 | soon 802 | worked 803 | staff 804 | agency 805 | view 806 | turned 807 | kilroy 808 | mike 809 | front 810 | member 811 | shot 812 | bush 813 | revealed 814 | areas 815 | download 816 | takes 817 | speed 818 | screen 819 | increased 820 | opposition 821 | university 822 | battle 823 | civil 824 | kennedy 825 | spend 826 | air 827 | finance 828 | newspaper 829 | him 830 | opportunity 831 | concerns 832 | shown 833 | survey 834 | area 835 | cross 836 | white 837 | gone 838 | voters 839 | course 840 | original 841 | millions 842 | bought 843 | offered 844 | £1 845 | poor 846 | alan 847 | followed 848 | east 849 | concerned 850 | leave 851 | often 852 | decided 853 | insisted 854 | authorities 855 | outside 856 | b 857 | favourite 858 | terms 859 | defence 860 | step 861 | all 862 | whose 863 | june 864 | story 865 | reached 866 | analyst 867 | lives 868 | created 869 | designed 870 | mini 871 | process 872 | non 873 | risk 874 | 22 875 | america 876 | body 877 | quality 878 | easy 879 | spent 880 | cuts 881 | becoming 882 | remains 883 | unit 884 | majority 885 | raise 886 | pop 887 | attempt 888 | musical 889 | r 890 | drugs 891 | hollywood 892 | challenge 893 | experience 894 | example 895 | 19 896 | debut 897 | nominated 898 | states 899 | reach 900 | credit 901 | messages 902 | levels 903 | winner 904 | ray 905 | robert 906 | silk 907 | watch 908 | andy 909 | situation 910 | focus 911 | taxes 912 | euro 913 | songs 914 | organisation 915 | build 916 | everything 917 | believed 918 | april 919 | tough 920 | central 921 | anyone 922 | signed 923 | j 924 | pcs 925 | captain 926 | rival 927 | device 928 | indian 929 | confirmed 930 | james 931 | so 932 | titles 933 | businesses 934 | post 935 | technologies 936 | critics 937 | matter 938 | previously 939 | trading 940 | rest 941 | met 942 | began 943 | longer 944 | officials 945 | response 946 | probably 947 | nine 948 | hour 949 | row 950 | minute 951 | light 952 | cases 953 | magazine 954 | building 955 | worth 956 | account 957 | voice 958 | programs 959 | ask 960 | looked 961 | mp 962 | davis 963 | aviator 964 | threat 965 | trust 966 | confidence 967 | looks 968 | g 969 | chinese 970 | machine 971 | gold 972 | category 973 | computers 974 | premiership 975 | host 976 | measures 977 | fast 978 | person 979 | ruled 980 | towards 981 | artists 982 | double 983 | training 984 | missed 985 | felt 986 | care 987 | agreement 988 | allowed 989 | madrid 990 | scheme 991 | zealand 992 | fear 993 | theatre 994 | portable 995 | newcastle 996 | north 997 | serious 998 | spain 999 | management 1000 | -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/Graded Assignments/week2-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 2 2 | 3 | week-2-quiz 4 | 5 | week-2-quiz 6 | 7 | week-2-quiz 8 | 9 | week-2-quiz 10 | 11 | week-2-quiz 12 | 13 | week-2-quiz 14 | 15 | week-2-quiz 16 | 17 | week-2-quiz -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/README.md: -------------------------------------------------------------------------------- 1 | # Word Embeddings 2 | 3 | One of the coolest things about word embedding is you can download the pretrained word embedding that maybe someone else has trained. 4 | 5 | ## TFDS 6 |

7 | tfds 8 | Images 1. TensorFlow Data Services 9 |

10 | TFDS contains many datasets and lots of different categories. 11 | 12 | ## Looking into Details 13 | ```python 14 | import tensorflow as tf 15 | print(tf.__version__) 16 | 17 | import tensorflow_datasets as tfds 18 | imdb, info = tfds.load("imdb_reviews", with_info=True, as_supervised=True) 19 | 20 | # split data for training and testing 21 | import numpy as np 22 | train_data, test_data = imdb['train'], imdb['test'] 23 | 24 | training_sentences = [] 25 | training_labels = [] 26 | 27 | testing_sentences = [] 28 | testing_labels = [] 29 | 30 | # each contains 25,000 sentences 31 | # label as sensors 32 | for s, l in train_data: 33 | training_sentences.append(str(s.numpy())) 34 | training_labels.append(l.numpy()) 35 | 36 | for s, l in test_data: 37 | testing_sentences.append(str(s.numpy())) 38 | testing_labels.append(l.numpy()) 39 | 40 | # Convert labels lists to numpy array 41 | training_labels_final = np.array(training_labels) 42 | testing_labels_final = np.array(testing_labels) 43 | ``` 44 | 45 | Sentimen analysis in TensorFlow uses emmedding. 46 | ```python 47 | tf.keras.layers.Embedding(vocab_size, emberdding_dim, input_length=max_length) 48 | ``` 49 | 50 | ## Use Vectors 51 | The meaning of the words can came from the labeling of the dataset. Resulf of embedding will beb a 2D array with the lenght of sentence. We use embedding layer to represent each word in vocabulary with vectors. 52 | 53 | ## Ungraded Labs 54 | * Lab 1: [Training a binary classifier with the IMDB Reviews Dataset](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W2/ungraded_labs/C3_W2_Lab_1_imdb.ipynb) 55 | * Lab 2: [Training a binary classifier with the Sarcasm Dataset](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W2/ungraded_labs/C3_W2_Lab_2_sarcasm_classifier.ipynb) 56 | * Lab 3: [Subword Tokenization with the IMDB Reviews Dataset](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W2/ungraded_labs/C3_W2_Lab_3_imdb_subwords.ipynb) 57 | 58 | ## Wrap Up 59 | Here are the key takeaways for this week: 60 | * You looked at taking your tokenized words and passing them to an Embedding layer. 61 | * Embeddings map your vocabulary to vectors in higher-dimensional space. 62 | * The semantics of the words were learned when those words were labeled with similar meanings. For example, when looking at movie reviews, those movies with positive sentiment had the dimensionality of their words ending up pointing a particular way, and those with negative sentiment pointing in a different direction. From these, the words in future reviews could have their direction established and your model can infer the sentiment from it. 63 | * You then looked at subword tokenization and saw that not only do the meanings of the words matter but also the sequence in which they are found. 64 | 65 | ## References 66 | * [IMDB Datasets](http://ai.stanford.edu/~amaas/data/sentiment/) 67 | * [TensorFlow Datasets Documentation](https://www.tensorflow.org/datasets/catalog/overview) 68 | * [SubTextEncoder](https://www.tensorflow.org/datasets/api_docs/python/tfds/deprecated/text/SubwordTextEncoder) -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/tfds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/tfds.png -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/1.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/2.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/3.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/4.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/5.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/6.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/7.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-2/img/week2-quiz/8.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/Graded Assignment/week3-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 3 2 | 3 | week-3-quiz 4 | 5 | week-3-quiz 6 | 7 | week-3-quiz 8 | 9 | week-3-quiz 10 | 11 | week-3-quiz 12 | 13 | week-3-quiz 14 | 15 | week-3-quiz 16 | 17 | week-3-quiz -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/README.md: -------------------------------------------------------------------------------- 1 | # Sequence Models 2 | 3 | ## Introduction 4 | The main reason for why our classifier failed to get any meaningful results was that the context of words was hard to follow when the words were broken down into sub-words and the sequence in which the tokens for the sub-words appear becomes very important in understanding their meaning. 5 | 6 |

7 | neural-network 8 | Images 1. Neural Network 9 |

10 | 11 | The neural network is like a function that when you feed it in data and labels, it infers the rules from these, and then you can use those rules. 12 | 13 |

14 | function 15 | Images 2. Function 16 |

17 | 18 | You take the data and you take the labels, and you get the rules. 19 | 20 |

21 | rnn 22 | Images 3. RNN 23 |

24 | 25 | Basic idea of a recurrent neural network or RNN, which is often drawn a little like this. You have your x as in input and your y as an output. But there's also an element that's fed into the function from a previous function. 26 | 27 | ## LSTMs (Long Short-term Memories) 28 | The context word that helps us understand the next word is very close to the word that we're interested in 29 | 30 |

31 | lstm 32 | Images 4. LSTM 33 |

34 | 35 | So, if we're looking at a sequence of words we might lose context. With that in mind an update to RNNs is called LSTM, long short - term memory has been created. In addition to the context being passed as it is in RNNs, LSTMs have an additional pipeline of contexts called cell state. This can pass through the network to impact it. This helps keep context from earlier tokens relevance in later ones. 36 | 37 |

38 | bidirection-lstm 39 | Images 5. Bidirection LSTM 40 |

41 | 42 | Cell states can also be bidirectional. So later contexts can impact earlier ones as we'll see when we look at the code. 43 | 44 | ## Implementing LSTMs in code 45 | ```python 46 | model = tf.keras.Sequential([ 47 | tf.keras.layers.Embedding(tokenizer.vocab_size, 64), 48 | tf.keras.layers.Bidirection(tf.keras.layers.LDTM(64)), 49 | tf.keras.layers.Dense(64, activation='relu'), 50 | tf.keras.layers.Dense(1, activation='sigmoid') 51 | ]) 52 | ``` 53 | 54 | Model Summary: 55 | 56 |

57 | model-summary 58 | Images 6. Model Summary 59 |

60 | 61 | You can also stack LSTMs like any other keras layer by using code like this. 62 | ```python 63 | model = tf.keras.Sequential([ 64 | tf.keras.layers.Embedding(tokenizer.vocab_size, 64), 65 | tf.keras.layers.Bidirection(tf.keras.layers.LSTM(64, retrun_sequences=True)), 66 | tf.keras.layers.Bidirection(tf.keras.layers.LSTM(32)), 67 | tf.keras.layers.Dense(64, activation='relu'), 68 | tf.keras.layers.Dense(1, activation='sigmoid') 69 | ]) 70 | ``` 71 | 72 | But when you feed an LSTM into another one, you do have to put the return sequences equal true parameter into the first one. This ensures that the outputs of the LSTM match the desired inputs of the next one. Model Summary: 73 | 74 |

75 | model-summary-2 76 | Images 7. Model Summary 2 77 |

78 | 79 | ## Accuracy and Loss 80 |

81 | comp-acc 82 | Images 8. One Layer and Two Layer LSTM Accuracy Comparison 83 |

84 | There's not much of a difference except the nosedive and the validation accuracy. But notice how the training curve is smoother 85 | 86 |

87 | 50epoch 88 | Images 10. 50 Epoch Accuracy Comparison 89 |

90 | If you look at loss, over the first 10 epochs, we can see similar results. 91 | 92 |

93 | 50epoch-loss 94 | Images 10. 50 Epoch Loss Comparison 95 |

96 | Our loss results are similar with the two layer having a much smoother curve. The loss is increasing epoch by epoch. So that's worth monitoring to see if it flattens out in later epochs as would be desired 97 | 98 | ## Looking into the code 99 | ```python 100 | model = tf.keras.Sequential([ 101 | tf.keras.layers.Embedding(vocab_size, embedding_dim, input_length=max_length), 102 | tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(32)), 103 | tf.keras.layers.Dense(24, activation='relu'), 104 | tf.keras.layers.Dense(1, activation='sigmoid') 105 | ]) 106 | ``` 107 | 108 | ## Ungraded Labs 109 | * Lab 1: [IMDB Subwords 8K with Single Layer LSTM](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W3/ungraded_labs/C3_W3_Lab_1_single_layer_LSTM.ipynb) 110 | * Lab 2: [IMDB Subwords 8K with Multi Layer LSTM](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W3/ungraded_labs/C3_W3_Lab_2_multiple_layer_LSTM.ipynb) 111 | * Lab 3: [Using Convolutional Neural Networks](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W3/ungraded_labs/C3_W3_Lab_3_Conv1D.ipynb) 112 | * Lab 4: [Building Models for the IMDB Reviews Dataset](https://github.com/https-deeplearning-ai/tensorflow-1-public/blob/main/C3/W3/ungraded_labs/C3_W3_Lab_4_imdb_reviews_with_GRU_LSTM_Conv1D.ipynb) 113 | * Lab 5: [Sarcasm with Bidirectional LSTM] 114 | * Lab 6: [Sarcasm with 1D Convolutional Layer] 115 | 116 | ## References 117 | * [Andrew - Sequence Models](https://www.coursera.org/lecture/nlp-sequence-models/deep-rnns-ehs0S) 118 | * [Andrew - LSTM](https://www.coursera.org/lecture/nlp-sequence-models/long-short-term-memory-lstm-KXoay) -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/50epoch-loss.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/50epoch-loss.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/50epoch.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/50epoch.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/acc-loss.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/acc-loss.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/bidirection-lstm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/bidirection-lstm.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/comp-acc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/comp-acc.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/comp-loss.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/comp-loss.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/function.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/function.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/lstm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/lstm.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/model-summary-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/model-summary-2.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/model-summary.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/model-summary.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/neural-network.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/neural-network.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/rnn.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/rnn.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/1.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/2.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/3.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/4.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/5.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/6.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/7.PNG -------------------------------------------------------------------------------- /3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/3. Natural Language Processing in TensorFlow/week-3/img/week3-quiz/8.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/lecture-notes/C4_W1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/lecture-notes/C4_W1.pdf -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/lecture-notes/C4_W2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/lecture-notes/C4_W2.pdf -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/lecture-notes/C4_W3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/lecture-notes/C4_W3.pdf -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/lecture-notes/C4_W4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/lecture-notes/C4_W4.pdf -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/Graded Assignment/week1-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 1 2 | 3 | week-1-quiz 4 | 5 | week-1-quiz 6 | 7 | week-1-quiz 8 | 9 | week-1-quiz 10 | 11 | week-1-quiz 12 | 13 | week-1-quiz 14 | 15 | week-1-quiz 16 | 17 | week-1-quiz 18 | 19 | week-1-quiz -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/README.md: -------------------------------------------------------------------------------- 1 | # Sequences and Prediction 2 | 3 | Take a look at some of the unique considerations involved when handling sequential time series data -- where values change over time, like the temperature on a particular day, or the number of visitors to your web site. We'll discuss various methodologies for predicting future values in these time series, building on what you've learned in previous courses! 4 | 5 | ## Introduction 6 | Time-series is one part of sequence models where it's a case of if you can imagine a series of data that changes over time. It might be the closing prices for stock on the stock exchange, or it could be weather. It could be how sunny it is in California on a given day, or how rainy it is in Seattle on a given day, that type of thing. So if you just imagine how an item of data changes over time and how it's measured over time. 7 | 8 | We're going to start by creating a synthetic sequence of data, so that we can start looking at what the common attributes that you see in data series are. So for example: 9 | * Data can be seasonal. It's sunnier in June than it is in January or it's wetter in November than it is in October, something along those lines. So you have that seasonality of data. 10 | * Data can have trends, like whether it probably doesn't really trend although we could argue that it strangely enough idea with climate change, but like a stock data may trend upwards over time or downwards over some other times, and then of course the random factor that makes it hard to predict is noise. 11 | 12 | So you can have like seasonal data, you can have trends in your data, but then you can have noise on that data as well. 13 | 14 | ## Time Series Example 15 | Different type of time series, looking at basic forecasting around them. Time series are everywhere. You may have seen them in stock prices, weather forecasts, historical trends, such as Moore's law. What exactly is a time series? It's typically defined as an ordered sequence of values that are usually equally spaced over time. So for example, every year in my Moore's law charts or every day in the weather forecast. 16 | 17 | In each of these examples, there is a single value at each time step, and as a results, the term **univariate** is used to describe them. You may also encounter time series that have multiple values at each time step. As you might expect, they're called **Multivariate Time Series**. 18 | 19 | Multivariate Time Series charts can be useful ways of understanding the impact of related data. For example, consider this chart of births versus deaths in Japan from 1950 to 2008. It clearly shows the two converging, but then deaths begin to outstrip births leading to a population decline. Now, while they could be treated as two separate univariate time series, the real value of the data becomes apparent when we show them together as a multivariate. 20 | 21 |

22 | sequences 23 |

24 | 25 | ## Machine learning applied to time series 26 | What can we do? 27 | 1. Forecasting based on the data, example: the birth and death rate chart for Japan. It would be very useful to predict future values so that government agencies can plan for retirement, immigration and other societal impacts of these trends. 28 | 2. Detect anomalies. For example, in website logs so that you could see potential denial of service attacks showing up as a spike on the time series like this. 29 | 3. Analyze the time series to spot patterns in them that determine what generated the series itself. A classic example of this is to analyze sound waves to spot words in them which can be used as a neural network for speech recognition. 30 | 31 | ## Common patterns in time series 32 | Time-series come in all shapes and sizes, but there are a number of very common patterns. 33 | 1. Trend, where time series have a specific direction that they're moving in. The general tendency of the values to go up or down as time progresses. 34 | 2. Seasonality, which is seen when patterns repeat at predictable intervals. For instance, the hourly temperature might oscillate similarly for 10 consecutive days and you can use that to predict the behavior on the next day. 35 | 3. Auto correlation, measurements at a given time step is a function of previous time steps 36 | 4. Noise, not predictable at all and just a complete set of random values producing what's typically called white noise 37 | 5. Non-stationary, break an expected pattern. Big events can alter the trend or seasonal behavior of the data, later its behavior does not change over time 38 | 39 | We always assume that more data is better. But for **time series forecasting it really depends on the time series**. If it's stationary, meaning its behavior does not change over time, then great. The more data you have the better. But if it's not stationary then the optimal time window that you should use for training will vary. Ideally, we would like to be able to take the whole series into account and generate a prediction for what might happen next. 40 | 41 | ## Train, validation and test sets 42 | **Naïve forecasting** is the technique in which the last period's sales are used for the next period's forecast without predictions or adjusting the factors. 43 | 44 | ### **How Do We Measure Performance?** 45 | To measure the performance of our forecasting model,. We typically want to split the time series into a training period, a validation period and a test period — **fixed partitioning.** 46 | 47 |

48 | fixed-partitioning 49 |

50 | 51 | We'll train the model on the training period, and we'll evaluate it on the validation period. And work in it and the hyperparameter, until we get the desired performance, measured using the validation set. Then, test on test period to see if the model will perform just as well. 52 | 53 | There is also another way to split training, validation and test sets with using **roll-forward partitioning.** 54 | 55 |

56 | roll-forward-partitioning 57 |

58 | 59 | ## Metrics for Evaluating Performance 60 | Metrics used to calculate model performance. 61 | 62 |

63 | metrics 64 |

65 | 66 | * Mean squared error (mse), square the errors and calculate their mean. It need to be squared because to get rid of negative values. 67 | * Square root, if we want the mean of our errors' calculation to be of the same as the original errors. 68 | * Mean absolute deviation (mae), instead of squaring to get rid of negatives we just uses their absolute value. 69 | * Mean absolute percentafe error (mape), the mean ratio between the absolute error and the absolute valuie. This give an idea of the size of the errors compared to the values. 70 | 71 | ### When to Use MSE and MAE? 72 | If large errors are potentially dangerous and they cost you much more than smaller errors, then you may prefer the mse. But if your gain or your loss is just proportional to the size of the error, then the mae may be better. 73 | 74 | ```python 75 | # Naive Forecast MAE 76 | keras.metrics.mean_absolute_error(x_valid, naive_forecast).numpy() 77 | ``` 78 | 79 | ## References 80 | * [Ungraded Lab - C4_W1_Lab_1_time_series](https://colab.research.google.com/drive/1_QdTh3jQxxAMCekxUbagkmL-mJKDUSom?usp=sharing) 81 | * [Ungraded Lab - C4_W1_Lab_2_forecasting](https://colab.research.google.com/drive/1MlZKLUVBQVLEvfPzeadeDMg7j8q11ozW?usp=sharing) 82 | * [Naïve Forecasting](https://www.avercast.in/blog/what-is-naive-forecasting-and-how-can-be-used-to-calculate-future-demand#:~:text=Na%C3%AFve%20forecasting%20is%20the%20technique,to%20the%20final%20observed%20value.) -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/birth-and-date.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/birth-and-date.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/fixed-partitioning.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/fixed-partitioning.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/metrics.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/metrics.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/roll-forward-partitioning.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/roll-forward-partitioning.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/1.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/2.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/3.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/4.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/5.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/6.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/7.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/8.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/9.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-1/img/week1-quiz/9.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/Graded Assignment/my_model.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/Graded Assignment/my_model.h5 -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/Graded Assignment/week2-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 2 2 | 3 | week-2-quiz 4 | 5 | week-2-quiz 6 | 7 | week-2-quiz 8 | 9 | week-2-quiz 10 | 11 | week-2-quiz 12 | 13 | week-2-quiz 14 | 15 | week-2-quiz 16 | 17 | week-2-quiz 18 | 19 | week-2-quiz 20 | 21 | week-2-quiz 22 | 23 | week-2-quiz -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/1.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/2.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/3.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/4.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/5.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/6 (1).PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/6 (1).PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/6 (2).PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/6 (2).PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/6.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/7.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/8.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/9.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-2/img/week2-quiz/9.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/Graded Assignment/week3-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 3 2 | 3 | week-3-quiz 4 | 5 | week-3-quiz 6 | 7 | week-3-quiz 8 | 9 | week-3-quiz 10 | 11 | week-3-quiz 12 | 13 | week-3-quiz 14 | 15 | week-3-quiz 16 | 17 | week-3-quiz 18 | -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/README.md: -------------------------------------------------------------------------------- 1 | # Recurrent Neural Networks for Time Series 2 | 3 | Recurrent Neural networks (RNN) and Long Short Term Memory (LSTM) networks are really useful to classify and predict on sequential data. 4 | 5 | ### Sequence Data 6 | Sequential Data is any kind of data where the order matters as you said. So we can assume that time series is a kind of sequential data, because the order matters. 7 | 8 | ### Sequence Model 9 | Sequence models are the machine learning models that input or output sequences of data. Sequential data includes text streams, audio clips, video clips, time-series data and etc. 10 | 11 | ### Lambda Layers 12 | Lambda layers allow us to write effectively an arbitrary piece of code as a layer in the neural network. Basically a Lambda function, an unnamed function, but implemented as a layer in the neural network that resend the data, scales it. More simply we can say that using the lambda layer we can transform the data before applying that data to any of the existing layers. 13 | 14 | ## Conceptual Overview 15 | One difference will be that the full input shape when using RNNs is three-dimensional. The first dimension will be the batch size, the second will be the timestamps, and the third is the dimensionality of the inputs at each time step. 16 | 17 |

18 | metrics 19 |

20 | 21 | What it looks like there's lots of cells, there's actually only one, and it's used repeatedly to compute the outputs. This is what gives this type of architecture the name a recurrent neural network, because the values recur due to the output of the cell, a one-step being fed back into itself at the next time step. 22 | 23 | ## When to Use RNN and LSTM 24 | RNNs are particularly suited for tasks that involve sequences (thanks to the recurrent connections). For example, they are often used for machine translation, where the sequences are sentences or words. In practice, an LSTM is often used, as opposed to a vanilla (or standard) RNN, because it is more computationally effective. In fact, the LSTM was introduced to solve a problem that standard RNNs suffer from, i.e. the vanishing gradient problem. (Now, for these tasks, there are also the transformers, but the question was not about them). 25 | 26 | ## References 27 | * [Sequence Models & Recurrent Neural Networks](https://towardsdatascience.com/sequence-models-and-recurrent-neural-networks-rnns-62cadeb4f1e1#:~:text=Sequence%20models%20are%20the%20machine,algorithm%20used%20in%20sequence%20models.&text=1.) 28 | * [Introduction to Sequence Modeling Problems](https://towardsdatascience.com/introduction-to-sequence-modeling-problems-665817b7e583) 29 | * [Ungraded Lab: Using a Simple RNN for forecasting](https://colab.research.google.com/github/https-deeplearning-ai/tensorflow-1-public/blob/main/C4/W3/ungraded_labs/C4_W3_Lab_1_RNN.ipynb) 30 | * [Ungraded Lab: Using a multi-layer LSTM for forecasting](https://colab.research.google.com/github/https-deeplearning-ai/tensorflow-1-public/blob/main/C4/W3/ungraded_labs/C4_W3_Lab_2_LSTM.ipynb) 31 | * [Huber Loss](https://en.wikipedia.org/wiki/Huber_loss) 32 | * [LSTM Lesson](https://www.coursera.org/lecture/nlp-sequence-models/long-short-term-memory-lstm-KXoay) -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/recurrent-layer.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/recurrent-layer.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/1.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/2.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/3.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/4.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/5.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/6.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/7.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-3/img/week3-quiz/8.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/Graded Assignment/week4-quiz.md: -------------------------------------------------------------------------------- 1 | # Graded Assignment - Quiz 4 2 | 3 | week-4-quiz 4 | 5 | week-4-quiz 6 | 7 | week-4-quiz 8 | 9 | week-4-quiz 10 | 11 | week-4-quiz 12 | 13 | week-4-quiz 14 | 15 | week-4-quiz 16 | 17 | week-4-quiz 18 | -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/1.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/2.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/3.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/4.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/5.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/6.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/7.PNG -------------------------------------------------------------------------------- /4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yoursemicolon/tensorflow-developer-professional-certificate/aff46653797933d83002a222d3d432aae22ee8eb/4. Sequences, Time Series and Prediction/week-4/img/week4-quiz/8.PNG -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DeepLearning.AI TensorFlow Developer Coursera 2 | 3 | This repository was created to collect my self-notes, codes and solutions of every videos / reading materials / questions / quizes / exercises while learning [TensorFlow Developer course](https://www.coursera.org/professional-certificates/tensorflow-in-practice) on Coursera by DeepLearning.AI taught by [Laurence Moroney](https://www.coursera.org/instructor/lmoroney). 4 | 5 | ## TensorFlow 6 | TensorFlow is one of the most in-demand and popular open-source deep learning frameworks available today. The DeepLearning.AI TensorFlow Developer Professional Certificate program teaches you applied machine learning skills with TensorFlow so you can build and train powerful models. 7 | 8 | ## Course Topics 9 | The topics covered in this course are: 10 | 1. [Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning](https://www.coursera.org/learn/introduction-tensorflow) 11 | * [Week 1](1.%20Introduction%20to%20TensorFlow/week%201/) A New Programming Paradigm 12 | * [Week 2](1.%20Introduction%20to%20TensorFlow/week%202/) Introduction to Computer Vision 13 | * [Week 3](1.%20Introduction%20to%20TensorFlow/week%203/) Enhancing Vision with Convolutional Neural Networks 14 | * [Week 4](1.%20Introduction%20to%20TensorFlow/week%204/) Using Real-world Images 15 | 2. [Convolutional Neural Networks in TensorFlow](https://www.coursera.org/learn/convolutional-neural-networks-tensorflow) 16 | * [Week 1]() Exploring a Larger Dataset 17 | * [Week 2]() Augmentation: A technique to avoid overfitting 18 | * [Week 3]() Transfer Learning 19 | * [Week 4]() Multiclass Classifications 20 | 3. [Natural Language Processing in TensorFlow](https://www.coursera.org/learn/natural-language-processing-tensorflow) 21 | * [Week 1]() Sentiment in text 22 | * [Week 2]() Word Embeddings 23 | * [Week 3]() Sequence models 24 | * [Week 4]() Sequence models and literature 25 | 4. [Sequences, Time Series and Prediction](https://www.coursera.org/learn/tensorflow-sequences-time-series-and-prediction) 26 | * [Week 1]() Sequences and Prediction 27 | * [Week 2]() Deep Neural Networks for Time Series 28 | * [Week 3]() Recurrent Neural Networks for Time Series 29 | * [Week 4]() Real-world time series data 30 | 31 | ## Certificate of Completion 32 | coming-soon. --------------------------------------------------------------------------------