Practice Exercises 100+ Problems
TensorFlow · PyTorch Hands‑On

Deep Learning Practice Exercises

Move from theory to implementation. 100+ graded exercises, coding challenges, and mini‑projects — from perceptrons to Vision Transformers.

45+

TensorFlow/Keras

40+

PyTorch

20+

GANs & Transformers

10

Capstone Projects

CNN RNN/LSTM Transformers GANs Autoencoders ResNet YOLO BERT

1. Neural Networks & Backpropagation

Implement building blocks from scratch and with frameworks.

Perceptron from scratch

Easy

Task: Implement a binary perceptron using only NumPy. Train it on synthetic linearly separable data (e.g., 2D points). Achieve 100% accuracy.

NumPy only 2 features
HINT: Use step activation; update rule: w += lr * (y_true - y_pred) * x.

MLP for XOR

Medium

Task: Build a 2-layer MLP with sigmoid/tanh to solve the XOR problem. Use backpropagation manually (no autograd). Plot decision boundary.

NumPy Manual grad

Fashion MNIST classifier

Easy

Task: Use TensorFlow/Keras to build a 3‑layer dense network for Fashion‑MNIST. Achieve ≥88% test accuracy. Apply dropout and batch normalization.

TensorFlow Accuracy >88%

2. Convolutional Neural Networks (CNN)

Conv2D manual forward

Hard

Task: Implement 2D convolution (without libraries) with stride and padding. Apply random filters on a sample image, visualize feature maps.

NumPy only input shape (1,28,28)

CNN for CIFAR-10

Medium

Task: Design a CNN with Conv+MaxPool+FC. Use PyTorch or TF to reach at least 75% accuracy on CIFAR‑10. Add data augmentation.

TensorFlow PyTorch target ≥75%

Implement Residual Block (ResNet)

Medium

Task: Create a residual block with skip connection. Use it to build a small ResNet-like model for CIFAR-10. Compare with plain CNN.

PyTorch Keras Get hint

3. Recurrent Neural Networks & Sequence Modeling

IMDB Sentiment – LSTM

Easy

Task: Use an embedding layer + LSTM to classify movie reviews (IMDB). Achieve >85% validation accuracy.

TF/Keras pad_sequences Solution

Time series forecasting (LSTM)

Medium

Task: Predict univariate time series (air passengers, stock) using LSTM. Implement sliding window and inverse scaling.

PyTorch window=12

4. Transformers & Attention

Scaled Dot‑Product Attention

Medium

Task: Implement `scaled_dot_product_attention` from scratch. Test with random Q,K,V matrices. Verify masking (optional).

NumPy PyTorch (compare) Code

Fine-tune BERT for sentiment

Advanced

Task: Use Hugging Face transformers. Fine-tune `bert-base-uncased` on SST-2 dataset. Achieve ≥90% accuracy.

PyTorch + HF HuggingFace Notebook

5. Generative Adversarial Networks (GANs)

Simple GAN on MNIST

Medium

Task: Implement a vanilla GAN with MLP generator/discriminator. Train on MNIST; show generated digits after 50 epochs.

TF/Keras PyTorch Solution (TF) PyTorch

DCGAN on CelebA

Hard

Task: Deep Convolutional GAN. Use stride convolutions for discriminator and transposed conv for generator. Generate 64x64 face images.

PyTorch CelebA Tutorial

6. Framework‑specific drills

TensorFlow custom training loop
Medium

Rewrite a Keras model using `tf.GradientTape`. Apply custom loss and metric.

Starter
PyTorch nn.Module – custom layer
Easy

Implement a custom linear layer with learnable parameters; register parameters manually.

Solution
Benchmark: TF vs PyTorch speed
Hard

Task: Train identical CNN on both frameworks, measure epoch time, GPU utilization. Write a short report.

7. Capstone Practice Projects

Object Detection – YOLOv1 from scratch

Implement a simplified YOLO detection head and loss function. Train on Pascal VOC subset.

PyTorch 2 weeks effort
Chatbot with Seq2Seq + Attention

Build a neural conversation model using LSTM encoder‑decoder with additive attention.

TF
Music generation with Transformer

Use a decoder‑only Transformer (GPT‑style) to generate piano rolls (MAESTRO dataset).

How to use these exercises?

  • Each exercise includes a short starter snippet (click "Starter"). We recommend forking our Colab.
  • Solutions are private initially; attempt at least 30 min before viewing.
  • Join #dl‑practice in Nikhil LearnHub community for discussions.
  • New exercises added weekly – challenge yourself with different frameworks.
13 of 100+ exercises shown View Full Project Catalogue