{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "rX8mhOLljYeM" }, "source": [ "# Lab 1: Deep Neural Networks" ] }, { "cell_type": "markdown", "metadata": { "id": "04QgGZc9bF5D" }, "source": [ "This Lab uses TensorFlow's Keras to:\n", "\n", "1. Load a prebuilt dataset.\n", "2. Build a simple neural network that classifies images.\n", "3. Train the neural network.\n", "4. Evaluate the accuracy of the network." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Grading Specifications\n", "\n", "◻ Filename changed to reflect last name of person submitting assignment \n", "◻ Code runs error free \n", "◻ All lines of code edited/changed contain comments with thought process behind methodology \n", "◻ Training and test data imported correctly \n", "◻ Training and test data normalized correctly \n", "◻ Maximum and minimum values of normalized dataset printed \n", "◻ DNN Layers (flatten, dense, dropout, dense) built in order and with parameters exactly as described in markdown \n", "◻ Model compiled with correct optimizer, loss function, and metric type \n", "◻ Model trained using training data for 5 epochs \n", "◻ Model evaluated using test data \n", "◻ Softmax layer appended to model after training \n", "◻ Predictions made using test data \n", "◻ For a single image, probability values (one per class) are printed \n", "◻ For a single image, the sum of probability values (one per class) is equal to 1 \n", "◻ Jupyter notebook is saved such that outputs appear upon opening file (and therefore on gradescope) \n", "◻ (Recommended) Results analyzed and discussed with classmates \n", "◻ (Recommended) All markdown and resources read thoroughly\n" ] }, { "cell_type": "markdown", "metadata": { "id": "nnrWf3PCEzXL" }, "source": [ "#### Set up\n", "\n", "**Ensure you are using your [495 Virtual Environment](https://kaitlin-fair.github.io/ECE495_Fa24/venv_setup.html) before you begin!** \n", " \n", "If you are using your virtual environment, when you run this section you should see that you are using TensorFlow version 2.10.1.\n", " \n", "Import TensorFlow and other libraries into your program to get started:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "executionInfo": { "elapsed": 150, "status": "ok", "timestamp": 1704916618629, "user": { "displayName": "Kaitlin Fair", "userId": "17700486897371704309" }, "user_tz": 420 }, "id": "0trJmd6DjqBZ", "outputId": "988634f1-82f2-4f87-e365-2d7af4b1c294" }, "outputs": [], "source": [ "import tensorflow as tf\n", "\n", "print(\"TensorFlow version:\", tf.__version__)\n", "\n", "# Helper libraries\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": { "id": "7NAbSZiaoJ4z" }, "source": [ "### Load a dataset\n", "\n", "Load and prepare the [MNIST dataset](https://en.wikipedia.org/wiki/MNIST_database). The pixel values of the images range from 0 through 255. For this network, we want to scale these values to a range of 0 to 1 (i.e. normalize the values) by dividing the values by `255.0`. This also converts the sample data from integers to floating-point numbers." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "