This laboratory introduces students to TensorFlow and Keras, Google's powerful open-source machine learning framework. Students will learn to build, train, and evaluate neural networks for image classification tasks using two fundamental datasets: MNIST and Fashion-MNIST. Through hands-on implementation on the NVIDIA Jetson Orin Nano, you'll develop practical skills in creating production-ready deep learning applications that can run efficiently on edge devices.
What You'll Learn
- TensorFlow Fundamentals: Understand TensorFlow's architecture and Keras high-level API
- Neural Network Construction: Build sequential models with dense layers and activation functions
- Data Preprocessing: Load, normalize, and prepare image datasets for training
- Model Training: Compile and train models with appropriate optimizers and loss functions
- Performance Evaluation: Assess model accuracy and analyze training/validation metrics
- GPU Acceleration: Leverage GPU capabilities on Jetson Orin Nano for faster training
💡 Why This Matters
TensorFlow powers many of the world's most advanced AI applications—from Google Translate to autonomous vehicles. By mastering TensorFlow and Keras on edge devices like the Jetson Orin Nano, you're preparing for the future of AI deployment where models must run efficiently on resource-constrained hardware. This hands-on experience bridges the gap between theoretical deep learning and practical, production-ready applications in computer vision, robotics, and IoT devices.
Lab Structure
This laboratory consists of two progressive parts, each building upon fundamental concepts:
- Part 1: MNIST Digit Classification - Training your first neural network to recognize handwritten digits (0-9)
- Part 2: Fashion-MNIST Classification - Advancing to clothing item recognition with 10 fashion categories
By the end of this laboratory session, you will be able to:
-
Install and configure TensorFlow on the Jetson Orin Nano platform and verify GPU availability for accelerated computing.
-
Build neural network architectures using Keras Sequential API with appropriate layer configurations and activation functions.
-
Load and preprocess image datasets including MNIST and Fashion-MNIST, applying normalization and proper data formatting.
-
Train neural networks effectively by selecting appropriate loss functions, optimizers, and training parameters for image classification tasks.
-
Evaluate model performance using accuracy metrics and analyze training history to identify overfitting or underfitting.
-
Make predictions with trained models and interpret classification results for new image data.
-
Deploy neural networks on edge devices by running TensorFlow models on Jetson Orin Nano for real-world AI applications.
Introduction to TensorFlow and Keras
TensorFlow is an open-source machine learning framework developed by Google that has become the industry standard for building and deploying deep learning models. It provides a comprehensive ecosystem of tools, libraries, and community resources that enable researchers and developers to build state-of-the-art machine learning applications. TensorFlow supports multiple programming languages and can run on various platforms—from mobile devices to distributed cloud systems.
Keras is a high-level neural networks API that runs on top of TensorFlow, providing a user-friendly interface for building deep learning models. It follows the principle of "simplicity for simple things, flexibility for complex things," allowing beginners to quickly build working models while still providing advanced users the flexibility to customize every aspect of their networks. Keras has become TensorFlow's official high-level API, integrated directly into TensorFlow 2.0 and later versions.
Neural Networks for Image Classification
Image classification is one of the fundamental tasks in computer vision, where a model learns to categorize images into predefined classes. Neural networks excel at this task by automatically learning hierarchical feature representations from raw pixel data. Unlike traditional computer vision approaches that require manual feature engineering, neural networks can discover the most relevant features directly from the training data through the learning process.
In this laboratory, you'll work with two classic image classification datasets: MNIST (handwritten digits) and Fashion-MNIST (clothing items). These datasets serve as excellent benchmarks for understanding how neural networks process and classify images. The MNIST dataset contains 70,000 grayscale images of handwritten digits (0-9), while Fashion-MNIST provides a more challenging alternative with 10 categories of clothing and accessories.
The Training Process
Training a neural network involves several key steps: data preparation, model definition, compilation, and training. During data preparation, images are normalized to improve training stability and convergence. Model definition involves specifying the network architecture—the number of layers, neurons per layer, and activation functions. Compilation sets up the learning process by selecting an optimizer (such as Adam or SGD), a loss function appropriate for the task, and metrics to monitor during training.
The actual training process iterates through the dataset multiple times (epochs), adjusting the network's weights to minimize the loss function through a process called gradient descent. The model learns to recognize patterns by seeing many examples and adjusting its internal parameters to improve predictions. This iterative learning process transforms random initial weights into a trained model capable of making accurate predictions on new, unseen data.
Edge AI with Jetson Orin Nano
The NVIDIA Jetson Orin Nano is a powerful edge AI platform that brings GPU-accelerated computing to embedded and edge devices. Unlike cloud-based AI, edge AI processes data locally on the device, enabling real-time inference with low latency, enhanced privacy, and reduced bandwidth requirements. The Jetson Orin Nano combines a powerful NVIDIA GPU with ARM CPU cores, providing the computational power needed to run sophisticated deep learning models efficiently.
TensorFlow is optimized for NVIDIA GPUs, allowing neural network training and inference to leverage parallel processing capabilities for significant speedups compared to CPU-only execution. In this lab, you'll verify GPU availability and see firsthand how TensorFlow automatically utilizes the Jetson's GPU to accelerate computations, making it practical to train and deploy neural networks directly on edge devices.
Before starting the laboratory exercises, review the following video tutorial and official TensorFlow documentation. These resources provide essential background knowledge on TensorFlow/Keras fundamentals and the image classification workflow you'll implement in this lab.
📺 Required Video Tutorials
TensorFlow Basics and Image Classification
Source: TensorFlow Official Tutorial
Written Tutorial:
📝 Pre-lab Quiz
Instructions: Complete this quiz after watching the required videos and reviewing the documentation to assess your readiness for the lab. These questions test your understanding of key concepts you'll need during the exercises.
Question 1: What is TensorFlow?
- A) A type of neural network architecture
- B) An open-source machine learning framework developed by Google
- C) A programming language specifically for AI
- D) A hardware accelerator for deep learning
Question 2: What is Keras?
- A) A standalone deep learning framework separate from TensorFlow
- B) A high-level API that runs on top of TensorFlow for building neural networks
- C) A visualization tool for neural networks
- D) A dataset repository for machine learning
Question 3: What is the MNIST dataset?
- A) A dataset of natural images from ImageNet
- B) A dataset of 70,000 grayscale images of handwritten digits (0-9)
- C) A collection of audio recordings for speech recognition
- D) A text corpus for natural language processing
Question 4: Why do we normalize image pixel values before training?
- A) To increase the image resolution
- B) To improve training stability and convergence by scaling values to a standard range
- C) To reduce the dataset size
- D) To add noise for data augmentation
Question 5: What does the Sequential model in Keras represent?
- A) A model that processes sequences of text data
- B) A linear stack of layers where each layer has one input and one output
- C) A model for time-series prediction only
- D) A parallel processing architecture
Question 6: What is the purpose of the Flatten layer in a neural network?
- A) To reduce the model's complexity
- B) To convert multi-dimensional input (like images) into a 1D vector for dense layers
- C) To compress the image size
- D) To apply activation functions
Question 7: Which optimizer is commonly recommended for training neural networks?
- A) Linear regression
- B) Adam (Adaptive Moment Estimation)
- C) K-means clustering
- D) Principal Component Analysis
Question 8: What does model.compile() do in Keras?
- A) Trains the model on the dataset
- B) Configures the model for training by specifying optimizer, loss function, and metrics
- C) Saves the model to disk
- D) Evaluates the model's performance
Question 9: What is an epoch in neural network training?
- A) A single training example
- B) A subset of the training data
- C) One complete pass through the entire training dataset
- D) The final layer of the network
Question 10: Why is GPU acceleration beneficial for training neural networks?
- A) It reduces the amount of training data needed
- B) It significantly speeds up matrix operations through parallel processing
- C) It automatically improves model accuracy
- D) It eliminates the need for data preprocessing
Note: Discuss your answers with your lab instructor before beginning the practical exercises. Understanding these concepts is crucial for successfully completing the lab.
This laboratory is divided into two parts, each focusing on building and training neural networks for image classification using TensorFlow and Keras. Complete each part sequentially, as Part 2 builds upon the concepts introduced in Part 1. Work through the exercises carefully and document your results for your lab report.
⚠️ Before You Begin:
- Ensure your Jetson Orin Nano is powered on and connected to the internet
- Verify that TensorFlow has been pre-configured by the lab technician
- Check GPU availability using the commands in Part 1
- Work through parts in order, as concepts build progressively
Part 1: MNIST Digit Classification
In this part, you'll build your first neural network using TensorFlow and Keras to classify handwritten digits from the MNIST dataset. You'll learn the complete workflow: loading data, building a model architecture, training the network, and evaluating its performance. This foundational exercise introduces you to TensorFlow's core concepts and the Keras Sequential API.
Key Topics:
- Checking TensorFlow installation and GPU availability
- Loading and preprocessing the MNIST dataset
- Building a Sequential model with Dense layers
- Training the model and monitoring accuracy
- Evaluating model performance on test data
- Making predictions on individual images
Part 2: Fashion-MNIST Classification
Building on Part 1, you'll now tackle a more challenging classification problem using the Fashion-MNIST dataset. This dataset contains images of 10 different clothing categories, providing a more realistic and complex task than digit recognition. You'll apply the same neural network techniques while exploring how model architecture choices affect performance on different types of image data.
Key Topics:
- Loading and exploring the Fashion-MNIST dataset
- Understanding image data shape and normalization
- Building neural networks for multi-class classification
- Training on more complex visual patterns
- Analyzing classification results across different categories
- Visualizing predictions and model confidence
Hardware Requirements
- Platform: NVIDIA Jetson Orin Nano Developer Kit (assembled in Week 1)
- Memory: Minimum 4GB RAM available for training
- Storage: At least 2GB free space for datasets and model checkpoints
- Connection: Internet access for downloading MNIST and Fashion-MNIST datasets
- Display: Monitor, keyboard, and mouse connected to Jetson
Software Prerequisites
Pre-installed by lab technician on your Jetson Orin Nano:
- Operating System: NVIDIA JetPack with Ubuntu 20.04/22.04
- Python: Version 3.8 or higher
- TensorFlow: Version 2.x optimized for Jetson (with GPU support)
- NumPy: For numerical computations
- Matplotlib: For visualizing images and results
- Jupyter Notebook: For running interactive code exercises
Datasets
- MNIST: Auto-downloaded by TensorFlow/Keras (approximately 11MB)
- Fashion-MNIST: Auto-downloaded by TensorFlow/Keras (approximately 30MB)
- Download Location: ~/.keras/datasets/ (automatic caching)
Primary Course Material
Source: TensorFlow Official Documentation
Topic: Basic Image Classification with TensorFlow/Keras
See Pre-lab Preparation section for complete video tutorial and written guide links
⚠️ Submission Deadline:
Submit your completed lab report by the end of Week 6. Late submissions will incur a penalty of 10% per day (maximum 3 days after the deadline).
Report Structure
Your lab report must include the following sections:
1. Title Page & Formatting (5 points)
- Lab title: "Week 5 - Introduction to TensorFlow"
- Your name, student ID, date of submission
- Course name and instructor name
- Professional formatting with clear headers and page numbers
2. Objectives (10 points)
- List all learning objectives from this laboratory
- For each objective, write 1-2 sentences explaining why it's important
- Demonstrate understanding of TensorFlow/Keras fundamentals
3. Procedure & Results (50 points)
For each of the 2 parts, provide:
- GPU Verification: Screenshot showing GPU availability check
- Code Implementation: Include key code snippets for model building and training
- Training Progress: Show training output including epoch-by-epoch accuracy/loss
- Model Evaluation: Report final test accuracy and evaluation metrics
- Predictions: Include screenshots of prediction examples with actual vs. predicted labels
- Explanations: Describe what each code section does and why
4. Discussion (20 points)
- Compare MNIST vs. Fashion-MNIST classification performance—which was easier and why?
- Analyze your model's accuracy: Is it good? Could it be improved? How?
- Discuss the role of normalization in improving training
- Explain how GPU acceleration affects training speed
- Support all statements with evidence from your experiments
5. Challenges & Solutions (10 points)
- Describe any problems you encountered (e.g., dataset download, GPU errors, model training issues)
- Explain your debugging process and how you resolved each issue
- Reflect on what you learned from troubleshooting
6. Conclusion (5 points)
- Summarize your key learnings about TensorFlow and Keras
- Reflect on the challenges faced during implementation
- Discuss potential real-world applications of image classification on edge devices
📋 Submission Checklist
- ✓ Completed all 2 lab parts with working code
- ✓ Included GPU verification screenshots
- ✓ Included training progress and final accuracy for both parts
- ✓ Added prediction examples with visualizations
- ✓ Provided thorough discussion comparing MNIST vs. Fashion-MNIST
- ✓ Documented challenges and solutions
- ✓ Wrote clear conclusions about TensorFlow capabilities
- ✓ Professional formatting throughout
📤 Submission Format
- File Format: PDF (required) - Do not submit Word documents
- Code Files: Include Jupyter notebooks (.ipynb) in a ZIP file
- File Naming: Week5_[LastName]_[StudentID].pdf
- Code ZIP Naming: Week5_[LastName]_[StudentID]_Code.zip
- Submission Method: Upload to the Learning Management System (LMS)
- Size Limit: 50MB maximum total (PDF + ZIP)
📊 Grading Rubric
| Component |
Points |
Criteria |
| Title Page & Formatting |
5 |
Complete information, professional appearance |
| Objectives |
10 |
Clear understanding, well-explained importance |
| Procedure & Results |
50 |
All parts complete, correct implementation, clear documentation |
| Discussion |
20 |
Thoughtful analysis, evidence-based, comparative insights |
| Challenges & Solutions |
10 |
Detailed problem-solving, reflective learning |
| Conclusion |
5 |
Comprehensive summary, insightful reflection |
| Total |
100 |
|
Grading Notes:
- All code must execute without errors on the Jetson Orin Nano
- Screenshots must be clear, properly labeled, and relevant
- Late penalty: 10% per day (maximum 3 days after deadline)
- Plagiarism or copying will result in zero credit for the assignment
- Include both MNIST and Fashion-MNIST results for full credit