312shan / pytorch-seq2seq-beam-search Goto Github PK
View Code? Open in Web Editor NEWPyTorch implementation for Seq2Seq model with attention and Greedy Search / Beam Search for neural machine translation
License: MIT License
PyTorch implementation for Seq2Seq model with attention and Greedy Search / Beam Search for neural machine translation
License: MIT License
Hi 312shan, great work!
I was analyzing your code and was curious about parts of the forward for the Decoder and Attention module.
. In the forward function of the Attention Module, you are doing
h = hidden.repeat(timestep, 1, 1).transpose(0, 1) # [32, 512]=>[32, 27, 512]
since you have passed the last layer of hidden state from Decoder's forward function as
attn_weights = self.attention(last_hidden[-1], encoder_outputs) # [32, 512][27, 32, 512]=>[32, 1, 27]
However, why is only the last of the hidden used? I'm assuming it's because of meeting matrix dimensionality requirements for the Attention Module, but lets say you specified multi-layers for the Decoder Module such as ,
decoder = Decoder(embed_size, hidden_size, en_size, n_layers=2, dropout=0.0)
Would this be losing half of information from the hidden state, that the Attention Module could have possibly used since you are only taking the last layer of the hidden state into account everytime?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.