Skip to content

ECM893/PyTorch-build

Repository files navigation

PyTorch Regression Example

This repo demonstrates how to build and experiment with simple regression models using PyTorch. It includes utilities for data generation, flexible model architectures, training scripts, and visualization of predictions. You can also explore the intracacies of single neuron or few neuron fittings to data and the impact of manual hyperparameter tuning.

Structure

  • data.py: Data generation utilities
  • models.py: Contains model architectures, including a dynamic MLP with customizable layers and activations
  • train_pytorch.py: Train and visualize regression using plain PyTorch. Edit the hyperparams dictionary in Section 2 to experiment with model architecture and training.
  • plotting.py: Functions for visualizing training loss, model fit, and extrapolation

Requirements

  • torch
  • pytorch-lightning
  • matplotlib
  • numpy

Install with:

pip install torch matplotlib numpy 

How to Use

  • Edit the hyperparams dictionary in train_pytorch.py (Section 2) to change the number of layers, hidden units, activation function, etc.
  • Run train_pytorch.py to see regression and extrapolation in action.

Next Steps

A follow-up repo will show how to use Ray Tune for easier hyperparameter optimization.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages