diff --git a/Badges/Intro-to-TF.pdf b/Badges/Intro-to-TF.pdf
new file mode 100644
index 0000000..37935fb
Binary files /dev/null and b/Badges/Intro-to-TF.pdf differ
diff --git a/Badges/Intro-to-TF.png b/Badges/Intro-to-TF.png
new file mode 100644
index 0000000..57218d3
Binary files /dev/null and b/Badges/Intro-to-TF.png differ
diff --git a/Course 1: Introduction to Tensorflow/README.md b/Course 1: Introduction to Tensorflow/README.md
index 9df7615..83041ba 100644
--- a/Course 1: Introduction to Tensorflow/README.md
+++ b/Course 1: Introduction to Tensorflow/README.md
@@ -59,6 +59,21 @@
### Week 4
+- Quiz:
+
+
+
+
+
+
+
+
+
+
+
+
+- [Programming assignment]().
+
## Contributors:
- 🐮 [@honghanhh](https://github.com/honghanhh)
diff --git a/Course 1: Introduction to Tensorflow/Week 3/Excercise-3-Question.ipynb b/Course 1: Introduction to Tensorflow/Week 3/Excercise-3-Question.ipynb
index 4610e8b..84caba2 100644
--- a/Course 1: Introduction to Tensorflow/Week 3/Excercise-3-Question.ipynb
+++ b/Course 1: Introduction to Tensorflow/Week 3/Excercise-3-Question.ipynb
@@ -72,7 +72,7 @@
" test_images = test_images.reshape(10000, 28, 28, 1)/255.0\n",
" # YOUR CODE ENDS HERE\n",
"\n",
- " model = tf.keras.models.Sequential([\n",
+ " model = Sequential([\n",
" # YOUR CODE STARTS HERE\n",
" Conv2D(64, (3,3), activation = 'relu', input_shape = (28,28,1)),\n",
" MaxPooling2D(2,2),\n",
@@ -96,9 +96,44 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "WARNING: Logging before flag parsing goes to stderr.\n",
+ "W1202 22:49:58.943024 139791317272384 deprecation.py:506] From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/init_ops.py:1251: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
+ "Instructions for updating:\n",
+ "Call initializer instance with the dtype argument instead of passing it to the constructor\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Epoch 1/20\n",
+ "60000/60000 [==============================] - 16s 265us/sample - loss: 0.1389 - acc: 0.9592\n",
+ "Epoch 2/20\n",
+ "60000/60000 [==============================] - 12s 205us/sample - loss: 0.0485 - acc: 0.9851\n",
+ "Epoch 3/20\n",
+ "60000/60000 [==============================] - 12s 203us/sample - loss: 0.0295 - acc: 0.9908\n",
+ "Epoch 4/20\n",
+ "60000/60000 [==============================] - 12s 200us/sample - loss: 0.0189 - acc: 0.9941\n",
+ "Epoch 5/20\n",
+ "60000/60000 [==============================] - 12s 200us/sample - loss: 0.0137 - acc: 0.9955\n",
+ "Epoch 6/20\n",
+ "60000/60000 [==============================] - 12s 194us/sample - loss: 0.0091 - acc: 0.9970\n",
+ "Epoch 7/20\n",
+ "60000/60000 [==============================] - 12s 195us/sample - loss: 0.0071 - acc: 0.9977\n",
+ "Epoch 8/20\n",
+ "59616/60000 [============================>.] - ETA: 0s - loss: 0.0057 - acc: 0.9981\n",
+ "Reached 99% accuracy so cancelling training!\n",
+ "60000/60000 [==============================] - 11s 190us/sample - loss: 0.0057 - acc: 0.9980\n"
+ ]
+ }
+ ],
"source": [
"_, _ = train_mnist_conv()"
]
@@ -163,4 +198,4 @@
},
"nbformat": 4,
"nbformat_minor": 1
-}
+}
\ No newline at end of file
diff --git a/Course 1: Introduction to Tensorflow/Week 4/Exercise4-Question.ipynb b/Course 1: Introduction to Tensorflow/Week 4/Exercise4-Question.ipynb
new file mode 100644
index 0000000..c5c9761
--- /dev/null
+++ b/Course 1: Introduction to Tensorflow/Week 4/Exercise4-Question.ipynb
@@ -0,0 +1,236 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "colab_type": "text",
+ "id": "UncprnB0ymAE"
+ },
+ "source": [
+ "Below is code with a link to a happy or sad dataset which contains 80 images, 40 happy and 40 sad. \n",
+ "Create a convolutional neural network that trains to 100% accuracy on these images, which cancels training upon hitting training accuracy of >.999\n",
+ "\n",
+ "Hint -- it will work best with 3 convolutional layers."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import tensorflow as tf\n",
+ "import os\n",
+ "import zipfile\n",
+ "from os import path, getcwd, chdir\n",
+ "from tensorflow.keras.models import Sequential\n",
+ "from tensorflow.keras.layers import Flatten, Dense, Conv2D, MaxPooling2D\n",
+ "from tensorflow.keras.callbacks import Callback\n",
+ "\n",
+ "# DO NOT CHANGE THE LINE BELOW. If you are developing in a local\n",
+ "# environment, then grab happy-or-sad.zip from the Coursera Jupyter Notebook\n",
+ "# and place it inside a local folder and edit the path to that location\n",
+ "path = f\"{getcwd()}/../tmp2/happy-or-sad.zip\"\n",
+ "\n",
+ "zip_ref = zipfile.ZipFile(path, 'r')\n",
+ "zip_ref.extractall(\"/tmp/h-or-s\")\n",
+ "zip_ref.close()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# GRADED FUNCTION: train_happy_sad_model\n",
+ "def train_happy_sad_model():\n",
+ " # Please write your code only where you are indicated.\n",
+ " # please do not remove # model fitting inline comments.\n",
+ "\n",
+ " DESIRED_ACCURACY = 0.999\n",
+ "\n",
+ " class myCallback(Callback): # your code\n",
+ " def on_epoch_end(self, epoch, logs={}):\n",
+ " if (logs.get('acc') > DESIRED_ACCURACY):\n",
+ " print(\"\\nReached ~100% accuracy so cancelling training!\")\n",
+ " self.model.stop_training = True\n",
+ " # Your Code\n",
+ "\n",
+ " callbacks = myCallback()\n",
+ " \n",
+ " # This Code Block should Define and Compile the Model. Please assume the images are 150 X 150 in your implementation.\n",
+ " model = Sequential([\n",
+ " # Your Code Here\n",
+ " Conv2D(16, (3,3), activation = 'relu', input_shape = (150,150,3)),\n",
+ " MaxPooling2D(2,2),\n",
+ " Conv2D(32, (3,3), activation = 'relu'),\n",
+ " MaxPooling2D(2,2),\n",
+ " Conv2D(64, (3,3), activation = 'relu'),\n",
+ " MaxPooling2D(2,2),\n",
+ " Flatten(),\n",
+ " Dense(512, activation = 'relu'),\n",
+ " Dense(1, activation = 'sigmoid')\n",
+ " ])\n",
+ "\n",
+ " from tensorflow.keras.optimizers import RMSprop\n",
+ "\n",
+ " model.compile(optimizer= RMSprop(lr = 0.001), loss='binary_crossentropy', metrics=['acc'])# Your Code Here #)\n",
+ " \n",
+ "\n",
+ " # This code block should create an instance of an ImageDataGenerator called train_datagen \n",
+ " # And a train_generator by calling train_datagen.flow_from_directory\n",
+ "\n",
+ " from tensorflow.keras.preprocessing.image import ImageDataGenerator\n",
+ "\n",
+ " train_datagen = ImageDataGenerator(rescale = 1./255) # Your Code Here\n",
+ "\n",
+ " # Please use a target_size of 150 X 150.\n",
+ " train_generator = train_datagen.flow_from_directory(\n",
+ " # Your Code Here)\n",
+ " # Expected output: 'Found 80 images belonging to 2 classes'\n",
+ " '/tmp/h-or-s/',\n",
+ " target_size = (150, 150),\n",
+ " batch_size = 128,\n",
+ " class_mode = 'binary'\n",
+ " )\n",
+ "\n",
+ " # This code block should call model.fit_generator and train for\n",
+ " # a number of epochs.\n",
+ " # model fitting\n",
+ " history = model.fit_generator(\n",
+ " # Your Code Here)\n",
+ " # model fitting\n",
+ " train_generator,\n",
+ " steps_per_epoch = 8,\n",
+ " epochs = 15,\n",
+ " callbacks = [callbacks],\n",
+ " verbose = 2\n",
+ " )\n",
+ " return history.history['acc'][-1]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "WARNING: Logging before flag parsing goes to stderr.\n",
+ "W1202 23:25:19.177921 140608713762624 deprecation.py:506] From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/init_ops.py:1251: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
+ "Instructions for updating:\n",
+ "Call initializer instance with the dtype argument instead of passing it to the constructor\n",
+ "W1202 23:25:19.543609 140608713762624 deprecation.py:323] From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/nn_impl.py:180: add_dispatch_support..wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n",
+ "Instructions for updating:\n",
+ "Use tf.where in 2.0, which has the same broadcast rule as np.where\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Found 80 images belonging to 2 classes.\n",
+ "Epoch 1/15\n",
+ "8/8 - 6s - loss: 2.5840 - acc: 0.6453\n",
+ "Epoch 2/15\n",
+ "8/8 - 2s - loss: 0.5867 - acc: 0.7781\n",
+ "Epoch 3/15\n",
+ "8/8 - 2s - loss: 0.4023 - acc: 0.8141\n",
+ "Epoch 4/15\n",
+ "8/8 - 2s - loss: 0.1744 - acc: 0.9625\n",
+ "Epoch 5/15\n",
+ "8/8 - 2s - loss: 0.1311 - acc: 0.9688\n",
+ "Epoch 6/15\n",
+ "8/8 - 2s - loss: 0.1083 - acc: 0.9672\n",
+ "Epoch 7/15\n",
+ "8/8 - 2s - loss: 0.1950 - acc: 0.9281\n",
+ "Epoch 8/15\n",
+ "8/8 - 2s - loss: 0.0395 - acc: 0.9953\n",
+ "Epoch 9/15\n",
+ "8/8 - 2s - loss: 0.0208 - acc: 0.9937\n",
+ "Epoch 10/15\n",
+ "\n",
+ "Reached ~100% accuracy so cancelling training!\n",
+ "8/8 - 2s - loss: 0.0090 - acc: 1.0000\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "1.0"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# The Expected output: \"Reached 99.9% accuracy so cancelling training!\"\"\n",
+ "train_happy_sad_model()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Now click the 'Submit Assignment' button above.\n",
+ "# Once that is complete, please run the following two cells to save your work and close the notebook"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%%javascript\n",
+ "\n",
+ "IPython.notebook.save_checkpoint();"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%%javascript\n",
+ "IPython.notebook.session.delete();\n",
+ "window.onbeforeunload = null\n",
+ "setTimeout(function() { window.close(); }, 1000);"
+ ]
+ }
+ ],
+ "metadata": {
+ "coursera": {
+ "course_slug": "introduction-tensorflow",
+ "graded_item_id": "1kAlw",
+ "launcher_item_id": "PNLYD"
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.6.8"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 1
+}
diff --git a/Course 1: Introduction to Tensorflow/img/w4_quizz1a.png b/Course 1: Introduction to Tensorflow/img/w4_quizz1a.png
new file mode 100644
index 0000000..a37bab2
Binary files /dev/null and b/Course 1: Introduction to Tensorflow/img/w4_quizz1a.png differ
diff --git a/Course 1: Introduction to Tensorflow/img/w4_quizz1b.png b/Course 1: Introduction to Tensorflow/img/w4_quizz1b.png
new file mode 100644
index 0000000..e168dac
Binary files /dev/null and b/Course 1: Introduction to Tensorflow/img/w4_quizz1b.png differ
diff --git a/Course 1: Introduction to Tensorflow/img/w4_quizz1c.png b/Course 1: Introduction to Tensorflow/img/w4_quizz1c.png
new file mode 100644
index 0000000..bd00ac9
Binary files /dev/null and b/Course 1: Introduction to Tensorflow/img/w4_quizz1c.png differ
diff --git a/README.md b/README.md
index cf6e814..2a12e9e 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,9 @@ This reporatory contains the solutions of every questions/quizes/exercises to ac
- [Course](https://www.coursera.org/learn/introduction-tensorflow)
- [Solution]()
+
+
+
### 2. Convolutional Neural Networks in TensorFlow