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.
data.py: Data generation utilitiesmodels.py: Contains model architectures, including a dynamic MLP with customizable layers and activationstrain_pytorch.py: Train and visualize regression using plain PyTorch. Edit thehyperparamsdictionary in Section 2 to experiment with model architecture and training.plotting.py: Functions for visualizing training loss, model fit, and extrapolation
- torch
- pytorch-lightning
- matplotlib
- numpy
Install with:
pip install torch matplotlib numpy
- Edit the
hyperparamsdictionary intrain_pytorch.py(Section 2) to change the number of layers, hidden units, activation function, etc. - Run
train_pytorch.pyto see regression and extrapolation in action.
A follow-up repo will show how to use Ray Tune for easier hyperparameter optimization.