Coder Social home page Coder Social logo

pytorch-ignite / examples Goto Github PK

View Code? Open in Web Editor NEW
10.0 6.0 11.0 6.64 MB

Examples, tutorials, and how-to guides

License: BSD 3-Clause "New" or "Revised" License

Jupyter Notebook 96.54% Python 3.46%
hacktoberfest pytorch-ignite tutorials how-to-guide examples

examples's People

Contributors

anirudhb11 avatar ishan-kumar2 avatar liviacavalcanti avatar mdrpanwar avatar miwojc avatar priyansi avatar puhuk avatar rmeli avatar sadra-barikbin avatar vfdev-5 avatar ydcjeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

Python environment to run "How To Guides"

In the how-to-guides sometimes dependencies are assumed, sometimes they are installed with

!pip install

I suggest to uniform this by providing a conda and/or requirements.txt file/s so that a full environment can be created.

Add frontmatter in notebooks

To make ease of converting notebook to markdown files, add a few frontmatter in the notebook as html comments.

Current frontmatter to add in a cell (this should be at the most top of the notebook)

<!-- ---
title: Example title
description: Example description
date: 2021-07-27
downloads: true
include_footer: true
sidebar: true
tags:
  - deep learning
  - machine learning
  - pytorch
  - python
--- -->

cc @trsvchn @Priyansi

Logging in Ignite

It would be nice to have a how-to guide combine all the built-in loggers that Ignite provides: ClearML, Tensorboard, MLflow, etc. See more here: https://pytorch.org/ignite/contrib/handlers.html#loggers.
The code on how to use these is already provided in https://github.com/pytorch/ignite/tree/master/examples/contrib/mnist.
When creating this new how-to guide, please:

  1. Create a Jupyter Notebook, see README.md.
  2. Follow the code under the basic setup of how-to guides. See this guide for reference.
  3. Add explanation while creating the loggers and how to use them.
  4. Run the notebook, so that the output is clearly visible, before submitting the PR.

Everyone is welcome to contribute! ๐Ÿš€ Please feel free to ask any further questions below.

How-to guide to cover multi-output models and their evaluation

The idea is to show how to tackle a use-case like:

x, y1, y2 = batch
y_pred1, y_pred2, aux = model(x)

and where we would like to compute metrics between y_pred1 vs y1 and y_pred2 vs y2.

  • Show that we can create custom evaluator that returns a dict
  • We attach metric and specify output_transform for each metric

Context: discussed on discord, "questions" channel, multi-output thread.

Rework cifar10 distributed tutorial

The idea is to restructure this tutorial in the following way:
We can provide 2 parts:

  1. minimal DDP code with 1 minimalistic trainer and 1 evaluator (computing accuracy metric) = goal to put the most pertinent info in minimum lines of text
  2. show how to add other features from current text: logging, resuming from checkpoint, etc.

@Priyansi @trsvchn what do you think ?

Add weight in frontmatter

Add weight in frontmatter of how to guides and tutorials pages. It could allow Hugo to sort the order of appearance.

See: https://gohugo.io/templates/lists#by-weight

TLDR; Lower number get higher precedence. So we shall start with 1. And I suggest to rename the file names to start with number like 01-file-name or 1-file-name so that it will show in order when viewing. And it could allow to scan the files.
It also allow us to see the files in order in the sidebar on the website.

For example:

01-installation
02-data-iterator
03-gradient-accumulation
04-fastai-lr-finder
05-time-profiling
...

cc @Priyansi @vfdev-5

Update `01-collective-communication` notebook regarding NCCL `gather` support

NCCL now supports gather operator. The line in bottom should be updated.

"**Note:** In the above example, only the main process required the gathered values and not all the processes. This can be also be done via the `gather()` method, however one of the backends [`nccl` does not support `gather()`](https://pytorch.org/docs/stable/distributed.html) hence we had to use `all_gather()`."

Split for summary

Hugo has built-in ability to split for summary from the markdown files.

Add <!--more--> (should be exact) where you want to show the summary as the content before <!--more-->.

OR

Add summary frontmatter if the summary doesn't look good from markdown content.

Link to <!--more-->

Example

This could allow the summary to be shown consistently on the website.

cc @Priyansi

Create How-To-Guides notebooks

Shift the files from pytorch-ignite/pytorch-ignite.github.io/content/docs/how-to-guides to pytorch-ignite/examples/how-to-guides and store them as .ipynb instead of .md

could you give an example of how to save checkpoints?

unfortunately, as i upgrade the ignite, i don't know how to save my model's checkpoints, becuase the save_interval is deprecated, my code is below, but it doesn' work.
checkpointer = ModelCheckpoint(output_dir, cfg.MODEL.NAME, n_saved=10, require_empty=False) trainer.add_event_handler(Events.EPOCH_COMPLETED(every=1), checkpointer, to_save={'model': model, 'optimizer': optimizer})

please give an example, thanks

Convert pure pytorch code to ignite

Following on the discussion with @vfdev-5 , this new how-to guide should be abstract and:

The purpose is to show explicitly how to convert pure pytorch code to ignite and explain what we gain by that

Topics to cover:

  • Training loop
  • Validation loop
  • Metrics
  • Checkpoints
  • LR Scheduler

cifar10 example is not scalable with multiple GPUs

I slightly adapted the cifar10 example in this fork, basically removing python-fire and adding the torch.distributed.launch function, so that it can be executed as a standalone script with clearml-task.

I executed the following script with nproc_per_node in [1, 2, 3, 4] on a AWS g4dn.12xlarge instance (x4 T4 GPUs). I got the following results:

  • batch size=16, nproc_per_node=1 => Runtime: 29:53
  • batch size=16, nproc_per_node=1 => Runtime: 05:34
    Here I disabled DataParallel as mentionned in pytorch/ignite#2447
  • batch size=32, nproc_per_node=2 => Runtime: 17:11
  • batch size=48, nproc_per_node=3 => Runtime: 11:33
  • batch size=64, nproc_per_node=4 => Runtime: 08:47

I am increasing the batch size by 16 each time I add a GPU, so that each GPU has the same number of samples. I didn't change the default number of processes (8) for all of them, because I didn't oberserve that the GPUs were under-used (below 95%)

GPU utilization as reported by clearml

newplot(8)

I was expecting to observe a quasi-linear time improvement, but it isn't the case. Am I missing something?

PS: Here are the requirements I used to execute the script

torch==1.7.1+cu110
torchvision==0.8.2
pytorch-ignite==0.4.8
clearml==.1.1.6
tensorboardX==2.4.1

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.