Giter VIP home page Giter VIP logo

pytorch-mini-tutorials's Introduction

pytorch-mini-tutorials's People

Contributors

esvhd avatar mattkleinsmith avatar vinhkhuc 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

pytorch-mini-tutorials's Issues

.forward is not recommended

doing .forward I believe is not recommended because it doesn't end up using masks or handle or something like that I forget...just heads up

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

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!

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())

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.

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.