Skip to main content

Fitting simple torch models

Project description

Fitting PyTorch models

License: MIT

This repository follows a workshop to set up a Python package, build some neural networks with torch, and publish the models on HuggingFace.

There are two datasets that we simulate:

  1. Colored shapes (circle, rectangle, triangle, diamond) in a pixellated image
  2. One-dimensional sinusoids

Alongside these datasets, we fit the following model objectives:

  1. (Classification) Predict the shape and color in the image
  2. (Regression) Predict the next time steps of the sine function

Usage

Learn how to train neural networks from scratch.

  1. Run answers/simulate-exercise.ipynb to get data.
  2. Fill in the # TO DO parts in examples/modeling-exercise-*.ipynb.
  3. Compare to solutions in answers/modeling-exercise-*.ipynb.
  4. You can explore different parameters on big models with modeling.py.
    • Write a shell script that invokes modeling.py and pass to slurm.

The package defined under src/ provides:

  • A class Shape that instantiates an image with 1 colored shape
  • A function simulate_shapes() to make many images for an image classifier
  • A model class MyCNN to fit a standard architecture

Caution: you may need GPU resources if your models or data are large.

Requirements

  • Python 3.10+

Install

If you want to install the package only from the internet:

pip install zootopia3

If you want to set up an isolated environment and build locally:

python -m venv path-to/your-environment
source path-to/your-environment/bin/activate
pip install -e .

You run the pip command within this repo.

Test

You can run the test scripts in tests/ with the following:

python -m pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zootopia3-0.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zootopia3-0.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file zootopia3-0.1.tar.gz.

File metadata

  • Download URL: zootopia3-0.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for zootopia3-0.1.tar.gz
Algorithm Hash digest
SHA256 990ee03d1ab89995335d09ed2d68c9354e03a6319dcf69ce3961e86afcb38829
MD5 8fd70614f18a98dd396d225a31668b01
BLAKE2b-256 34c652e91866af98bfc1fbf521b87929963394cfb757070cd0d79ab9710d7b04

See more details on using hashes here.

File details

Details for the file zootopia3-0.1-py3-none-any.whl.

File metadata

  • Download URL: zootopia3-0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for zootopia3-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc3d7504402e3df0945223245c42c09c013c1a0ac99c223b6069ebcecdf0bb99
MD5 85d1a9114f67ea6a3841ce3b2a852326
BLAKE2b-256 4832be2203d88754c8083453fc2185a09f6fb13e59eb87733644c7aa0fdd967b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page