This is a comprehensive assessment of all material covered in Weeks 1-5 of ELEC 395. The midterm examination consists of both written and practical components designed to evaluate your understanding of artificial intelligence fundamentals, neural networks, PyTorch programming, and hardware integration with Jetson Nano and JetBot platforms.
π
Date & Time
Week 6
During scheduled lab time
β±οΈ
Duration
1-2 Hours
Total examination time
π
Format
Hybrid
Written + Practical
π―
Total Points
100
Written: 50 | Practical: 50
π Exam Coverage
The midterm examination will assess your knowledge and skills across the following areas:
Week 1: Python for hardware, Jetson Nano & Raspberry Pi, JetBot assembly and components
Week 5: PyTorch/TensorFlow implementations, practical deep learning applications
π Open/Closed Book Policy
To Be Determined: Your instructor will announce whether this exam is open-book or closed-book during the review session. Please check your course announcements for the final policy.
Suggested: Prepare as if it's closed-book, then you'll be ready for either format!
π
Detailed Topics Covered
Below is a comprehensive breakdown of topics from Weeks 1-5 that will be assessed in the midterm examination:
Week 1
Python for Real Hardware - Jetson & Raspberry Pi
Key Topics:
Introduction to NVIDIA Jetson Nano Developer Kit specifications and capabilities
Raspberry Pi hardware architecture and comparison with Jetson
JetBot robot assembly process and component identification
Overfitting: Model memorizes training data, poor generalization
Underfitting: Model too simple, poor performance on both training and test data
Week 3: PyTorch & Neural Networks
PyTorch Essentials:
1. Tensor Operations:
import torch
# Creating tensors
x = torch.tensor([1, 2, 3])
y = torch.zeros(3, 3)
z = torch.randn(2, 3) # Random normal distribution
# Common operations
a = x.reshape(3, 1) # Reshape
b = x.view(1, 3) # View (similar to reshape)
c = torch.cat([x, y]) # Concatenate
d = x.unsqueeze(0) # Add dimension
# Moving to GPU
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
x = x.to(device)
2. Building Neural Networks:
import torch.nn as nn
# Method 1: Sequential
model = nn.Sequential(
nn.Linear(784, 256),
nn.ReLU(),
nn.Linear(256, 10),
nn.Softmax(dim=1)
)
# Method 2: Custom Class
class NeuralNet(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(784, 256)
self.fc2 = nn.Linear(256, 10)
def forward(self, x):
x = torch.relu(self.fc1(x))
x = self.fc2(x)
return x
3. Training Loop Pattern:
import torch.optim as optim
# Setup
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)
# Training loop
for epoch in range(num_epochs):
for images, labels in train_loader:
# Forward pass
outputs = model(images)
loss = criterion(outputs, labels)
# Backward pass
optimizer.zero_grad()
loss.backward()
optimizer.step()
print(f'Epoch {epoch+1}, Loss: {loss.item():.4f}')
4. Important Concepts:
optimizer.zero_grad(): Must clear gradients before each backward pass
.backward(): Computes gradients via backpropagation
optimizer.step(): Updates model parameters using computed gradients
model.train() vs model.eval(): Different behavior for dropout/batch normalization
Week 4: CNNs & Image Datasets
Convolutional Neural Networks:
1. CNN Architecture Components:
Convolutional Layer: Applies filters to extract features
# Save model
torch.save(model.state_dict(), 'model.pth')
# Load model
model = MyModel()
model.load_state_dict(torch.load('model.pth'))
model.eval()
2. GPU Utilization:
# Check GPU availability
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print(f"Using device: {device}")
# Move model and data to GPU
model = model.to(device)
inputs = inputs.to(device)
labels = labels.to(device)
3. Common Debugging Tips:
Shape Mismatches: Use .shape to debug tensor dimensions
NaN Loss: Check for exploding gradients, reduce learning rate
GPU Out of Memory: Reduce batch size or model complexity
No Learning: Verify optimizer is updating parameters, check learning rate
4. PyTorch vs TensorFlow:
Aspect
PyTorch
TensorFlow
Computation
Dynamic (define-by-run)
Static (define-then-run)
Debugging
Easier (Pythonic)
More complex
Production
Growing support
Mature ecosystem
Community
Research-focused
Industry-focused
π₯ Download Complete Study Guide
Get the comprehensive PDF study guide with all formulas, code examples, and quick reference materials.
β
Sample Written Questions
Practice with these sample multiple-choice questions covering all weeks. Click on your answer to check if it's correct.
Question 1: Hardware Specifications (Week 1)
What is the GPU architecture used in the NVIDIA Jetson Nano Developer Kit?
A) Pascal architecture with 256 cores
B) Maxwell architecture with 128 cores
C) Turing architecture with 64 cores
D) Volta architecture with 192 cores
Question 2: Activation Functions (Week 2)
Which activation function has an output range of (0, 1) and is commonly used in the output layer for binary classification?
A) ReLU (Rectified Linear Unit)
B) Sigmoid
C) Tanh (Hyperbolic Tangent)
D) Softmax
Question 3: Gradient Descent (Week 2)
In the gradient descent update rule ΞΈ = ΞΈ - Ξ± Γ βJ(ΞΈ), what does Ξ± represent?
A) The gradient of the cost function
B) The learning rate
C) The momentum parameter
D) The regularization coefficient
Question 4: PyTorch Tensors (Week 3)
What is the primary difference between tensor.reshape() and tensor.view() in PyTorch?
A) reshape() is faster than view()
B) view() can only be used on contiguous tensors
C) reshape() returns a copy if needed, view() requires contiguous memory
D) There is no difference, they are identical
Question 5: Training Loop (Week 3)
Why is optimizer.zero_grad() necessary in the PyTorch training loop?
A) To initialize the optimizer parameters
B) To clear accumulated gradients from the previous iteration
C) To reset the model weights to zero
D) To enable gradient computation
Question 6: CNN Components (Week 4)
What is the primary purpose of a pooling layer in a Convolutional Neural Network?
A) To increase the spatial dimensions of feature maps
B) To reduce spatial dimensions and extract dominant features
C) To apply non-linear transformations
D) To normalize the activations
Question 7: Output Size Calculation (Week 4)
Given an input image of size 32Γ32, a convolutional layer with kernel size 5Γ5, stride 1, and padding 2, what is the output size?
A) 28Γ28
C) 30Γ30
B) 32Γ32
D) 34Γ34
Question 8: Fashion-MNIST Dataset (Week 3)
How many classes are in the Fashion-MNIST dataset?
A) 10 classes
B) 26 classes
C) 100 classes
D) 1000 classes
Question 9: Overfitting (Week 2)
Which of the following is a symptom of overfitting in a neural network?
A) High training error and high validation error
B) Low training error but high validation error
C) High training error but low validation error
D) Low training error and low validation error
Question 10: Loss Functions (Week 2)
Which loss function is most appropriate for a multi-class classification problem with mutually exclusive classes?
A) Mean Squared Error (MSE)
B) Binary Cross-Entropy
C) Categorical Cross-Entropy
D) Hinge Loss
Question 11: CIFAR-10 Dataset (Week 4)
What are the dimensions of each image in the CIFAR-10 dataset?
A) 28Γ28 grayscale
B) 32Γ32 RGB color
C) 64Γ64 RGB color
D) 224Γ224 RGB color
Question 12: Backpropagation (Week 2)
What is the primary purpose of the backpropagation algorithm?
A) To make forward predictions through the network
B) To compute gradients of the loss with respect to network parameters
C) To normalize the input data
D) To initialize network weights
Question 13: Model Evaluation (Week 3)
What is the purpose of calling model.eval() in PyTorch?
A) To start the training process
B) To set the model to evaluation mode, disabling dropout and batch normalization updates
C) To evaluate the loss function
D) To compute model accuracy
Question 14: Data Augmentation (Week 4)
Which of the following is NOT a common data augmentation technique for image data?
A) Random horizontal flipping
B) Random rotation
C) Random cropping
D) Feature scaling
Question 15: GPU Computing (Week 5)
Which PyTorch command checks if CUDA (GPU) is available?
A) torch.cuda.is_available()
B) torch.has_cuda()
C) torch.gpu.check()
D) torch.device.cuda()
π Additional Question Types
The actual exam will also include:
Short Answer Questions: Explain concepts in 3-5 sentences (e.g., "Explain why ReLU is preferred over Sigmoid in hidden layers")
Diagram Questions: Draw and label neural network architectures, CNN structures, or training flowcharts
Code Reading: Identify errors or explain what given code snippets do
π»
Sample Coding Problems
Practice these coding problems to prepare for the practical component of the exam. Solutions are password-protected.
Problem 1: Tensor Operations (Easy) - 8 Points
Task: Complete the following function that creates a 3Γ3 tensor filled with random values from a normal distribution, then computes its transpose and returns both tensors.
import torch
def create_and_transpose():
"""
Create a 3x3 tensor with random normal values
and return both the original and transposed tensor.
Returns:
tuple: (original_tensor, transposed_tensor)
"""
# YOUR CODE HERE
pass
# Test your function
original, transposed = create_and_transpose()
print("Original tensor:")
print(original)
print("\nTransposed tensor:")
print(transposed)
Expected Skills: Tensor creation, random initialization, transpose operation
Problem 2: Activation Function Implementation (Easy) - 8 Points
Task: Implement the sigmoid activation function from scratch using NumPy or PyTorch. Do not use built-in activation functions.
import torch
import math
def sigmoid(x):
"""
Implement the sigmoid activation function.
Args:
x: Input tensor
Returns:
Tensor with sigmoid applied element-wise
"""
# YOUR CODE HERE
# Formula: Ο(x) = 1 / (1 + e^(-x))
pass
# Test your function
x = torch.tensor([-2.0, -1.0, 0.0, 1.0, 2.0])
result = sigmoid(x)
print(f"Input: {x}")
print(f"Sigmoid output: {result}")
print(f"Expected: [0.1192, 0.2689, 0.5000, 0.7311, 0.8808]")
Problem 3: Build a Simple Neural Network (Medium) - 10 Points
Task: Create a simple 2-layer neural network for binary classification using PyTorch. The network should have:
Input layer: 10 features
Hidden layer: 5 neurons with ReLU activation
Output layer: 1 neuron with Sigmoid activation
import torch
import torch.nn as nn
class BinaryClassifier(nn.Module):
def __init__(self):
super(BinaryClassifier, self).__init__()
# YOUR CODE HERE
# Define the layers
pass
def forward(self, x):
# YOUR CODE HERE
# Implement forward pass
pass
# Test your model
model = BinaryClassifier()
test_input = torch.randn(1, 10) # Batch of 1, 10 features
output = model(test_input)
print(f"Output shape: {output.shape}")
print(f"Output value (should be between 0 and 1): {output.item():.4f}")
Problem 4: Training Loop Implementation (Medium) - 10 Points
Task: Complete the training loop for a neural network. You need to fill in the missing steps.
import torch
import torch.nn as nn
import torch.optim as optim
# Assume model, train_loader are already defined
def train_one_epoch(model, train_loader, criterion, optimizer):
"""
Train the model for one epoch.
Args:
model: Neural network model
train_loader: DataLoader with training data
criterion: Loss function
optimizer: Optimizer
Returns:
float: Average loss for the epoch
"""
model.train()
total_loss = 0
for batch_idx, (data, target) in enumerate(train_loader):
# Step 1: Clear gradients
# YOUR CODE HERE
# Step 2: Forward pass
# YOUR CODE HERE
# Step 3: Compute loss
# YOUR CODE HERE
# Step 4: Backward pass
# YOUR CODE HERE
# Step 5: Update parameters
# YOUR CODE HERE
total_loss += loss.item()
avg_loss = total_loss / len(train_loader)
return avg_loss
Expected Skills: Training loop structure, gradient handling, loss computation
Task: Build a complete convolutional neural network to classify MNIST digits. Your solution should include:
CNN architecture with at least 2 convolutional layers
Proper data loading and preprocessing
Training loop for 3 epochs
Evaluation on test set
import torch
import torch.nn as nn
import torch.optim as optim
from torchvision import datasets, transforms
# 1. Define your CNN architecture
class MNISTClassifier(nn.Module):
def __init__(self):
super(MNISTClassifier, self).__init__()
# YOUR CODE HERE
# Should include:
# - At least 2 Conv2d layers
# - Pooling layers
# - Fully connected layers
pass
def forward(self, x):
# YOUR CODE HERE
pass
# 2. Data loading and preprocessing
def load_data():
# YOUR CODE HERE
# Load MNIST dataset with appropriate transforms
pass
# 3. Training function
def train_model(model, train_loader, criterion, optimizer, epochs=3):
# YOUR CODE HERE
pass
# 4. Evaluation function
def evaluate_model(model, test_loader):
# YOUR CODE HERE
# Should return accuracy
pass
# Main execution
if __name__ == "__main__":
model = MNISTClassifier()
train_loader, test_loader = load_data()
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)
train_model(model, train_loader, criterion, optimizer)
accuracy = evaluate_model(model, test_loader)
print(f"Test Accuracy: {accuracy:.2f}%")
Expected Skills: Complete ML pipeline, CNN architecture, data handling, training and evaluation
Target: Achieve >95% accuracy on MNIST test set
β° Time Management for Practical Section
Easy Problems (8 pts each): Allocate 6-8 minutes per problem
Medium Problems (10 pts each): Allocate 8-10 minutes per problem
Hard Mini-Project (14 pts): Allocate 20-25 minutes
Testing: Always leave 5 minutes to test your code before submission
βοΈ
Exam Policies & Guidelines
π« Academic Integrity Policy
Zero Tolerance: The following actions are strictly prohibited and will result in immediate failure of the exam and potential disciplinary action:
Copying answers from other students or external sources
Communicating with other students during the exam (verbally, digitally, or by any means)
Using unauthorized materials or resources
Accessing internet resources during closed-book sections (if applicable)
Taking pictures or screenshots of exam questions
Sharing exam content with students who haven't taken it yet
Using AI assistants (ChatGPT, Claude, etc.) to generate answers
Remember: Academic integrity is fundamental to your education. Violations will be reported to university administration.
π What to Bring
Required Items:
β Valid student ID card
β Writing materials (pens, pencils, erasers)
β Laptop with fully charged battery (for practical section)
β Power adapter/charger
β Calculator (if permitted by instructor)
Conditionally Allowed (Check with instructor):
? Personal notes (if open-book format)
? Textbooks or printed course materials
? PyTorch documentation (printed or digital)
Strictly Prohibited:
β Mobile phones (must be turned off and stored away)
β Smart watches or fitness trackers
β Headphones or earbuds
β Tablets (unless specifically approved as laptop alternative)
β Any communication devices
π₯οΈ Software & Environment Setup
Before the Exam: Ensure your laptop has the following installed and working:
Access these helpful resources for your exam preparation:
π Getting Help Before the Exam
Office Hours: Attend instructor office hours for clarification on confusing topics
Teaching Assistants: TAs are available for review sessions and questions
Study Groups: Form or join study groups with classmates
Course Forum: Post questions on the course discussion board
Email Instructor: For urgent questions or special accommodations
Pre-Exam Review Session: Check course announcements for a scheduled review session before the midterm. This is your opportunity to ask any last-minute questions!
πͺ Final Encouragement
You've worked hard through the first five weeks of this course, building hands-on skills with neural networks, PyTorch, and embedded AI systems. The midterm examination is an opportunity to demonstrate what you've learned and identify areas for continued growth.
Remember:
The exam tests understanding, not just memorization
Partial credit is awarded for showing your thought process
It's okay to not know everything - focus on what you do know
Your preparation and effort matter more than perfection
This is one assessment of many - learning is a continuous journey