Giter Club home page Giter Club logo

pytorch-template's Introduction

pytorch-template

repo-status: work in progress

This is a template for a pytorch project on linux.

The documentation folder docs provides basic documenation on how to set up a python project in a linux environment. The Project structure shows the organization and overview of all files included in this template.

Getting Started

Read the Python Set Up Guide for a detailed description of the tools and how to set up Python projects in Linux. Below are the steps to set up and configure this specific template:

  1. Click on the green button "Use this template" on GitHub.
  2. Open VS Code and clone the repository.
  3. Install global tools for linting etc.
    • make help to see the available commands.
    • make install-global to install packages such as pre-commit, poetry, and black globally using pipx.

Set up a Virtual Environment

You can use the pyproject.toml file to set up a virtual environment. This ensures all Python dependencies and the scripts in src\py-scripts are installed in the environment.

Here we use Poetry as the package manager. The Python Set Up Guide provide more information on poetry and other package managers such as pipenv and conda.

To set up a Poetry virtual environment, follow these steps:

# Navigate to your project directory where your pyproject.toml is located
cd /path/to/your/project

# Install the project dependencies
poetry install

# Activate the virtual environment
poetry shell

In Visual Studio Code, you can set the Python Interperater to the poetry virtual environment by clicking on the Python version in the footer.

  • Select Interpreter project-name-xxxxx-py.x.xx (poetry)
  • Path tot the virtual environment: /home/user.name/.cache/pypoetry/virtualenvs/pytorch-template-wSTEexrb-py3.10/bin/python

Configure your paths and parameters

Set up and check the project configuration files:

Test that your configuration files are set up correctly by running the following command:

# Test your conifguration
python src/config.py

# should print out the path to your project data directory
> Loading catalog...
> Project data directory: /path/to/your/project/data

Scripts and Notebooks

For each project you can create a notebook in the notebooks/ directory. The notebooks are designed to be run in a Jupyter or Colab environment and they utilize the scripts in the src/ directory.

Note: If you run the notebooks in Colab, you will need to upload the /data, /src and /config directories to the Colab environment. You can do this by zipping the directories and uploading them to Colab.

# upload the src/ directory to the Colab environment
from google.colab import files
uploaded = files.upload()

# unzip the file
!unzip src.zip
!ls src

See notebook-template for an example of how to configure your notebook for use in Colab. This includes uploading of files, adding your local modules to the path, setting up logging and configuring the catalog.

Linting and Pre-commit Hooks

It is recommended to run pre-commit hooks and linting before committing your code. This ensures that the code is formatted correctly.

Use the following commands to run linting and pre-commit hooks:

  • make codestyle to run black, isort and ruff.
  • make pre-commit to run pre-commit on all files.

Linters creates cache directories starting with . in the project root. Add these to your .gitignore file. You can also clean the whole project by running make clean.

List of usefull VS Code extensions

Python

  • Python
  • Pylance
  • Python Debugger
  • Python Environment Manager
  • Python Extension Pack

Jupyter

  • Jupyter
  • Jupyter Cell Tags

Maps, Figures and Documentation

  • Geo Data Viewer (view vectors)
  • Draw.io
  • Quarto
  • Live Server

Version Control

  • Git History
  • Git Graph
  • GitHub Copilot
  • GitLab Workflow

Containers and Remote Machines

  • Remote - SSH
  • Docker
  • Dev Containers

pytorch-template's People

Contributors

ac-willeke avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.