Coder Social home page Coder Social logo

pytorch_tutorial's Introduction

PyTorch Tutorial

This repository contains material to get started with PyTorch v1.7. It was the base for this [pytorch tutorial] from PyData Berlin 2018.


Table of Contents

PART 0 - Foreword

  • Foreword - Why PyTorch and why not? Why this talk?

PART 1 - Basics

PART 2 - Computer Vision

PART 3 - Misc, Cool Applications, Tips, Advanced

PART -2 - WIP and TODO

  • TODO nn and nn.Module
  • TODO Deployment
  • TODO Deployment with TF Serving
  • TODO nn.init
  • TODO PyTorch C++ frontend

PART -1 - The End


Setup

Requirements

  • Python 3.8

Install Dependencies

python3.8 -m venv .venv
source .venv/bin/activate.fish
pip install -r requirements.txt

Optional

Run the following to enable the jupyter table of contents plugin:

jupyter labextension install @jupyterlab/toc

jupyter nbextension enable --py widgetsnbextension

Download data and models

Download data and models for the tutorial:

python download_data.py

Then you should be ready to go. Start jupyter lab:

jupyter lab

Prior Versions

pytorch_tutorial's People

Contributors

johanjeppsson avatar satybald avatar sotte avatar zioalex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytorch_tutorial's Issues

Could not install conda environment on OS X

Hi Stefan,

first of all, thanks for providing the install instruction for the tutorial in advance :-)
However, I am struggling to install the dependencies on Mac OS X (e.g. the libgcc-ng package). Does the tutorial only work on Linux?

Why `loss.backward(loss)` in the Linear Regression example training

Thanks for putting up the notebooks and the code! I enjoyed watching your presentation and following along with the notebooks.

One question that bothered me is why you put the loss back in as the gradient for the backward method: loss.backward(loss) when training the linear regression network in the 01_pytorch_basics.ipynb notebook. Is this just an error?

just want to say thanks

today, I went through this tutorial of yours and it really helped me in learning basics.
Thanks. :-)

Loss and accuracy calculation

Hallo.

Great tutorial!
In your loss and accuracy calculations you divide the loss and correct with the length of the entire data set like this:

Train Loss: running_loss / len(train_dl.dataset)
Train Acc: correct / len(train_dl.dataset)

Shouldn't it be the loss and correct divided by the batch size? Then you get the accuracy of the current batch like this:

    ite = 0
    for i, (X, y) in enumerate(train_dl):
        X, y = X.to(DEVICE), y.to(DEVICE)

        optimizer.zero_grad()
        y_ = model(X)
        loss = criterion(y_, y)
        loss.backward()
        optimizer.step()

        # Statistics
        _, y_label_ = torch.max(y_, 1)
        correct += (y_label_ == y).sum().item()
        running_loss += loss.item() * X.shape[0]
        ite = i
    print(f"  Train Loss: {running_loss / ite+1}")
    print(f"  Train Acc:  {correct /  ite+1}")

Edit: Nevermind, i am an idiot. Because you go through x images per batch you divide with number of images and what i do is dividing the loss and correct with number of batches. I will never get the correct loss

Just close this issue

2nd Edit: Okay so i found this https://discuss.pytorch.org/t/interpreting-loss-value/17665/9
They claim that the loss should be calculated in a different way. Who is right i cannot say.

One of the best PyTorch that I ever encountered!

I want to say that is a great source of learning, especially because it treats practical problems like:
Transfer Learning, PyTorch in production, along with many other interesting topics.
Most of the tutorials that I found online are just a "getting started kit" with 90% of the work focused on very basic stuff, while the other tutorials that I found were really hard to understand in the sense that the code wasn't explained and the solutions were just given at a plate along with the fact that they were not practically oriented.

A big round of applause for you, sir!
Can't wait for the final parts of the tutorial to be released!

ModuleNotFoundError: No module named 'ppt'

Sorry, but I got this error and don't know what should I do!!
I installed python-pptx, but it didn't work.
could you please tell me how to install that module?
thank you!

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.