1.3 GB
78 files
Updated about 1 month ago
Name
Size
README.md4.66 kB
xet
a5_S25_notebook.ipynb46.8 kB
xet
iris.csv3.98 kB
xet
titanic.csv60.3 kB
xet
README.md

Assignment 5: Introduction to PyTorch

Attribution

When using or sharing this material, please include the following attribution:

Originally developed by Fareya Ikram, Tuhina Tripathi, Varun Gandhi, and Hunter McNichols as part of the course COMPSCI 383 Artificial Intelligence at the University of Massachusetts Amherst.
Shared under the CC BY 4.0 License.

Overview

This assignment introduces you to PyTorch, one of the most popular deep learning frameworks used in industry and research. You'll learn the fundamentals of PyTorch's tensor operations and build neural network models to solve classification problems.

Learning Objectives

By completing this assignment, you will:

  • Understand PyTorch tensors and their operations
  • Learn how to create and manipulate tensors
  • Implement basic machine learning models using PyTorch
  • Build and train a multi-layer perceptron (MLP) neural network
  • Experiment with hyperparameter tuning for model optimization

Assignment Structure

Section 1: PyTorch Tensors

In this section, you'll learn about PyTorch tensors - the fundamental data structure for deep learning operations. You'll explore tensor creation, manipulation, and various operations that are essential for building neural networks.

Section 2: Machine Learning Workflow (Demo)

This section demonstrates a complete machine learning workflow using the Iris dataset. You'll see how to:

  • Load and preprocess data
  • Create custom datasets and dataloaders
  • Build a simple logistic regression model
  • Train the model and evaluate its performance

Section 3: Multi-Layer Perceptron with Titanic Dataset

In this section, you'll apply what you've learned to build a more complex neural network - a Multi-Layer Perceptron (MLP) - to predict survival on the Titanic. You'll:

  • Preprocess the Titanic dataset
  • Create a custom dataset class
  • Build an MLP model with multiple layers
  • Train and evaluate the model
  • Experiment with hyperparameter tuning to improve performance

Why PyTorch?

PyTorch has become one of the most popular frameworks for deep learning research and applications for several reasons:

  1. Intuitive Design: PyTorch offers a natural, Pythonic interface that makes it easy to learn and use.

  2. Dynamic Computation Graph: Unlike some other frameworks, PyTorch builds the computation graph dynamically, allowing for more flexible model architectures and easier debugging.

  3. Rich Ecosystem: PyTorch has a vibrant community and extensive libraries for various applications, including computer vision, natural language processing, and reinforcement learning.

  4. Industry Adoption: Many top tech companies and research institutions use PyTorch for their AI projects.

  5. Seamless Integration: PyTorch works well with Python's scientific computing stack (NumPy, pandas, etc.).

Prerequisites

To succeed in this assignment, you should have:

  • Basic understanding of Python programming
  • Familiarity with NumPy arrays
  • Basic knowledge of machine learning concepts
  • Understanding of neural networks and backpropagation

Getting Started

  1. Read through the entire notebook to get an overview of the assignment
  2. Complete the sections marked with "TODO" comments
  3. Test your code frequently to ensure it's working correctly
  4. Experiment with different parameters and architectures in Section 3.5
  5. Submit your completed notebook for evaluation

Resources

Important Notes

  • Pay attention to tensor shapes and dimensions
  • Remember to move tensors to the appropriate device (CPU/GPU) if applicable to your setup
  • Watch out for common errors like using different data types or tensors on different devices
  • Don't forget to zero gradients before backpropagation

Submission

  • To make a submission for the project, submit a pdf of PytorchStudentViewV1 jupyter notebook under Assignment 5 - Introduction to Pytorch on Gradescope.
  • How to generate a pdf of your jupyter notebook:
    • On your Github repository after finishing the assignment, click on PytorchStudentViewV.ipynb to open the markdown preview.
    • Ensure that the notebook has outputs for all the cells included
    • Use your browser's "Print to PDF" feature to save your PDF.
    • On Gradescope, please assign the pages of your pdf to the specific questions/sections outlined.

Good luck, and enjoy building your first PyTorch models!

Total size
1.3 GB
Files
78
Last updated
Oct 18
Pre-warmed CDN
US EU US EU

Contributors