Skip to content

A beginner-friendly project demonstrating the core workflow (data, model, loss, optimization, training) of a deep learning model using PyTorch, applied to the fundamental task of learning a straight line

License

Rahmat-ML/PyTorch-Linear-DNN-Fundamentals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTorch-Linear-DNN-Fundamentals

This project serves as a step-by-step introduction to the PyTorch deep learning workflow, demonstrating how a simple neural network learns the pattern of a straight line (y = weight * x + bias).

It implements the full cycle of data preparation, model construction, training, evaluation, and saving/loading, following a device-agnostic approach (works on both CPU and GPU).

Core Concepts Explained

A deep learning workflow typically involves these steps:

  1. Data Preparation: Create and split the dataset (training, testing).
  2. Model Building: Define the neural network architecture.
  3. Loss Function & Optimizer: Define how the model measures errors (Loss) and how it updates its parameters to reduce those errors (Optimizer).
  4. Training Loop: The iterative process of Forward Pass, Loss Calculation, Backpropagation, and Optimizer Step.
  5. Inference: Using the trained model to make predictions.
  6. Saving/Loading: Persisting the learned parameters.

Files

  • linear_regression_pytorch.py: The main, self-contained Python script implementing the entire workflow.
  • requirements.txt: Lists necessary Python libraries.

Setup and Running

1. Prerequisites

You need Python (3.8+) and the following libraries:

torch
matplotlib

2. Run Locally (Recommended)

  1. Clone the repository:

    git clone https://github.com/Rahmat-ML/PyTorch-Linear-DNN-Fundamentals
    cd PyTorch-Linear-DNN-Fundamentals
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run the script:

    python linear_regression_pytorch.py
    

    The script will print training progress, model parameters, and save plots/the final model state.

About

A beginner-friendly project demonstrating the core workflow (data, model, loss, optimization, training) of a deep learning model using PyTorch, applied to the fundamental task of learning a straight line

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published