Minimal tutorials for PyTorch

Comments
  • Py36 fix

    Py36 fix

    Hi,

    This is related to #3 changes to make these scripts work for Python 3.x.

    I tested these changes with Anaconda Python 3.6.

    Hope this helps.

    Thanks.

    opened by esvhd 4
  • About CrossEntroyLoss

    About CrossEntroyLoss

    The pytorch document shows:

    class torch.nn.CrossEntropyLoss(weight=None, size_average=True)[source]
    This criterion combines LogSoftMax and NLLLoss in one single class.
    

    SO could I remove softmax layer from the model sequential?

    model.add_module("softmax", torch.nn.Softmax())
    
    opened by SmartAI 2
  • Including Multiple Independent Variable in Linear Model

    Including Multiple Independent Variable in Linear Model

    Hi Vinh Khuc,

    Thanks for creating this wonderful tutorial for pytorch. I was trying your examples to learn pytorch. For linear regression, I was trying a variant so that I understand better the inner working of pytorch. So, instead of using single independent variable, I'm using multiple independent variable (2 Xs, X1 and X2). I created them as following in the training function. Rest of the code is exactly the same as you have created.

    X1 = torch.linspace(-2, 2, 101)
    X2 = torch.linspace(-1, 1, 101)
    X = torch.cat(([X1, X2])).resize_(100,2)
    

    But when I'm using batch_size = 10, I'm getting the following error:

    RuntimeError Traceback (most recent call last) in () 4 for k in range(num_batches): 5 start, end = k * batch_size, (k + 1) * batch_size ----> 6 cost += train(model, loss, optimizer, X[start:end], Y[start:end]) 7 print("Epoch = %d, cost = %s" % (i + 1, cost / num_batches)) 8

    in train(model, loss, optimizer, x, y) 7 8 # Forward ----> 9 fx = model.forward(x.view(len(x), 1)) 10 output = loss.forward(fx, y) 11

    C:\Program Files\Anaconda3\lib\site-packages\torch\autograd\variable.py in view(self, *sizes) 466 467 def view(self, *sizes): --> 468 return View.apply(self, sizes) 469 470 def view_as(self, tensor):

    C:\Program Files\Anaconda3\lib\site-packages\torch\autograd_functions\tensor.py in forward(ctx, i, sizes) 87 ctx.new_sizes = sizes 88 ctx.old_size = i.size() ---> 89 result = i.view(*sizes) 90 ctx.mark_shared_storage((i, result)) 91 return result

    RuntimeError: size '[10 x 1]' is invalid for input of with 20 elements at D:\Downloads\pytorch-master-1\torch\lib\TH\THStorage.c:59

    So, I'm not understanding, why I'm getting this error. If you could guide me then it will be a great help to me.

    Thank you!

    opened by Aarijit 1
  • Minor changes for Python 3.x compatibility

    Minor changes for Python 3.x compatibility

    Hi there,

    Thanks for sharing this great set of tutorials. I made a few tiny changes to make it work for Python 3.x. Would you be interested in a pull request?

    Changes:

    1. use integer division for calculating minibatch size
    2. use urllib.reqeust.urlretrieve() if python major version is > 2
    3. download MNIST files if any of the data files is missing, instead of just checking folder existence.

    Thanks.

    opened by esvhd 1
  • Replace .next() with next() for py3 compatibility

    Replace .next() with next() for py3 compatibility

    In Python3:

    AttributeError                            Traceback (most recent call last)
    <ipython-input-16-dc3a6e32cc0b> in <module>()
          1 
    ----> 2 w = model.parameters().next().data # model has only one parameter
    
    AttributeError: 'generator' object has no attribute 'next'
    

    next() works in python 2 and python 3. .next() only works in python 2.

    opened by MattKleinsmith 1
  • GPU versions of example 3 to 6

    GPU versions of example 3 to 6

    Hi @vinhkhuc ,

    Would you be interested in a PR for the cuda version of these 4 models? I made some simple modifications to make them work on GPUs, while trying to preserve the flow of the original non-GPU versions.

    Example 1 & 2 probably doesn't need a GPU version since they train quite fast anyway.

    Thx

    opened by esvhd 0
Owner
Vinh Khuc
Machine Learning, NLP and Computer Vision enthusiast.
Vinh Khuc
C++ Implementation of PyTorch Tutorials for Everyone

C++ Implementation of PyTorch Tutorials for Everyone OS (Compiler)\LibTorch 1.9.0 macOS (clang 10.0, 11.0, 12.0) Linux (gcc 8, 9, 10, 11) Windows (msv

Omkar Prabhu 1.5k Jan 4, 2023
Simple PyTorch Tutorials Zero to ALL!

PyTorchZeroToAll Quick 3~4 day lecture materials for HKUST students. Video Lectures: (RNN TBA) Youtube Bilibili Slides Lecture Slides @GoogleDrive If

Sung Kim 3.7k Dec 30, 2022
PyTorch tutorials and best practices.

Effective PyTorch Table of Contents Part I: PyTorch Fundamentals PyTorch basics Encapsulate your model with Modules Broadcasting the good and the ugly

Vahid Kazemi 1.5k Jan 4, 2023
A set of examples around pytorch in Vision, Text, Reinforcement Learning, etc.

PyTorch Examples WARNING: if you fork this repo, github actions will run daily on it. To disable this, go to /examples/settings/actions and Disable Ac

null 19.4k Jan 1, 2023
Deep Learning (with PyTorch)

Deep Learning (with PyTorch) This notebook repository now has a companion website, where all the course material can be found in video and textual for

Alfredo Canziani 6.2k Jan 2, 2023
Open source guides/codes for mastering deep learning to deploying deep learning in production in PyTorch, Python, C++ and more.

Deep Learning Materials by Deep Learning Wizard Start Learning Now Please head to www.deeplearningwizard.com to start learning! It is mobile/tablet fr

Ritchie Ng 572 Dec 28, 2022
Simple examples to introduce PyTorch

This repository introduces the fundamental concepts of PyTorch through self-contained examples. At its core, PyTorch provides two main features: An n-

Justin Johnson 4.4k Jan 7, 2023
PyTorch Tutorial for Deep Learning Researchers

This repository provides tutorial code for deep learning researchers to learn PyTorch. In the tutorial, most of the models were implemented with less

Yunjey Choi 25.4k Jan 5, 2023
PyTorch Implementation of Fully Convolutional Networks. (Training code to reproduce the original result is available.)

pytorch-fcn PyTorch implementation of Fully Convolutional Networks. Requirements pytorch >= 0.2.0 torchvision >= 0.1.8 fcn >= 6.1.5 Pillow scipy tqdm

Kentaro Wada 1.6k Jan 4, 2023
Pytorch implementations of various Deep NLP models in cs-224n(Stanford Univ)

DeepNLP-models-Pytorch Pytorch implementations of various Deep NLP models in cs-224n(Stanford Univ: NLP with Deep Learning) This is not for Pytorch be

Kim SungDong 2.9k Dec 24, 2022
A scalable template for PyTorch projects, with examples in Image Segmentation, Object classification, GANs and Reinforcement Learning.

PyTorch Project Template is being sponsored by the following tool; please help to support us by taking a look and signing up to a free trial PyTorch P

Mo'men AbdelRazek 740 Dec 23, 2022
Some example scripts on pytorch

pytorch-practice Some example scripts on pytorch CONLL 2000 Chunking task Uses BiLSTM CRF loss with char CNN embeddings. To run use: cd data/conll2000

Shubhanshu Mishra 180 Dec 22, 2022
Example of network fine-tuning in pytorch for the kaggle competition Dogs vs. Cats Redux: Kernels Edition

Example of network fine-tuning in pytorch for the kaggle competition Dogs vs. Cats Redux: Kernels Edition Currently

bobby 70 Sep 22, 2022
ConvNet training using pytorch

Convolutional networks using PyTorch This is a complete training example for Deep Convolutional Networks on various datasets (ImageNet, Cifar10, Cifar

Elad Hoffer 336 Dec 30, 2022
simple generative adversarial network (GAN) using PyTorch

Generative Adversarial Networks (GANs) in PyTorch Running Run the sample code by typing: ./gan_pytorch.py ...and you'll train two nets to battle it o

vanguard_space 32 Jun 14, 2020
Torch Containers simplified in PyTorch

pytorch-containers This repository aims to help former Torchies more seamlessly transition to the "Containerless" world of PyTorch by providing a list

Max deGroot 88 Apr 25, 2022
The Hitchiker's Guide to PyTorch

The Hitchiker's Guide to PyTorch

Kai Arulkumaran 1k Dec 20, 2022
Minimal diffusion models - Minimal code and simple experiments to play with Denoising Diffusion Probabilistic Models (DDPMs)

Minimal code and simple experiments to play with Denoising Diffusion Probabilist

Rithesh Kumar 16 Oct 6, 2022
The Incredible PyTorch: a curated list of tutorials, papers, projects, communities and more relating to PyTorch.

This is a curated list of tutorials, projects, libraries, videos, papers, books and anything related to the incredible PyTorch. Feel free to make a pu

Ritchie Ng 9.2k Jan 2, 2023
Simple tutorials on Pytorch DDP training

pytorch-distributed-training Distribute Dataparallel (DDP) Training on Pytorch Features Easy to study DDP training You can directly copy this code for

Ren Tianhe 188 Jan 6, 2023