Git Product home page Git Product logo

understanding-pytorch-batching-lstm's Introduction

Understanding and visualizing PyTorch Batching with LSTM

This is a small notebook that I wrote to help me understand how batching was done in PyTorch with an Recurrent Neural Network (LSTM).

Please, if you see anything wrong within this notebook feel free to contribute or submit an issue, I may have misunderstood/misinterpreted/misrepresented some things here.

The point here wasn't to build a state of the art model but visualize properly how PyTorch handle the tensors while batching them into an LSTM.

Thanks to Tushar-N from which I inspired this repo and of cours the Classifying Names with a Character-Level RNN PyTorch tutorial.

understanding-pytorch-batching-lstm's People

Contributors

ngarneau 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

understanding-pytorch-batching-lstm's Issues

question regarding the prediction stage

Hi there,

first of all, very nice tutorials you have written. But I have a short question regarding the prediction stage at the end.
lstm_out, indices = F.max_pool1d(lstm_out, lstm_out.size(2), return_indices=True) # Figure 9
Why do you need max_pooling over the entire sequence again and not just take the last output stage of the lstm model? I have also seen some model, where people just use the last output stage to do further predictions.

Thanks! :-)

Error when running the notebook

Hi,
when I am trying to run the notebook with python 3.6 I keep getting this error message:
RuntimeError: Expected hidden[0] size (1, 32, 32), got (2, 32, 32)
I think the problem starts here, but I am not sure:
---> 26 packed_output, (ht, ct) = self.lstm(packed_input, self.hidden) # Figure 6

It would be very helpful for me if you could fix the error and thus having a running example again.

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.