Git Product home page Git Product logo

pytorch-cleancode's Introduction

Pytorch clean code

Overall goal: Standardise pytorch code among deep learning research to allow researchers to focus on developing models An advice given to me by a PhD student studying at CMU with regards to being a good deep learning research is to first be able to learn how to write good code in deep learning

Important aspects for clean code

  1. Reproducibility

Todo List

  • Expand section on distributed programming
  • setting up the environment section
    • virtual environment
    • requirements.txt
    • allowing users to install easily
  • improving the development process
    • commit messages
    • code styles
  • Create auto generator for new NLP project with pytorch
    • Write down the steps when running a new NLP project
    • Find a repository as an example
  • Write an article on medium on GLIP implementation and code structure
    • list possible books on good code structure
    • Read up on pytorch 2.0 features
  • Find ways to optimize github repository

This is a repository documenting clean code guidelines for developing pytorch models

Links to repository with clean code:

Building datasets

Dataset template card: https://github.com/huggingface/datasets/blob/main/templates/README_guide.md

creating new AI models for research

folders for a new project
  1. config folder: Contains a set of yaml files for your dataset configurations
tips
  1. use distributed data parallelism: https://pytorch.org/tutorials/intermediate/ddp_tutorial.html#initialize-ddp-with-torch-distributed-run-torchrun
  • to date, command is torchrun --nnodes=2 --nproc_per_node=8

Dealing with secrets:

If you have secrets such as API keys to use in your repository, you can create a .env file and place it under your gitignore file, you should also provide an env.example file to provide a template for your original env file https://dev.to/edgar_montano/how-to-setup-env-in-python-4a83#:~:text=How%20to%20setup%20a%20.env%20file%201%201.To,file%20using%20the%20following%20format%3A%20...%20More%20items

Steps:

  1. pip install python-dotenv file
  2. create a .env file and a .env.example file
  3. Add the .env to your gitignore
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())

Styling your outputs

Coloring command line outputs

  1. Colorama
    from colorama import Fore 
    print(Fore.RED) + "text message here in red"
    
    examples:

pytorch-cleancode's People

Contributors

clarence-lee-sheng avatar

Watchers

Kostas Georgiou avatar  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.