In this tutorial, it teaches how to develop a simple encoder-decoder model with attention using pytorch.
However, in the encoder or decoder, self.embedding = nn.Embedding(input_size, hidden_size) (or similar) is defined. In pytorch documents, nn.Embedding is defined as "A simple lookup table that stores embeddings of a fixed dictionary and size."
So I am confused that, in the initialization, where does this lookup table has come from? Does it initialize some random embeddings for the indices and then they will be trained? Is it really necessary to be in the encoder/decoder part?
Thanks in advance.
how does nn.embedding for developing an encoder-decoder model works?
606 Views Asked by Kadaj13 At
1
There are 1 best solutions below
Related Questions in MACHINE-LEARNING
- How to cluster a set of strings?
- Enforcing that inputs sum to 1 and are contained in the unit interval in scikit-learn
- scikit-learn preperation
- Spark MLLib How to ignore features when training a classifier
- Increasing the efficiency of equipment using Amazon Machine Learning
- How to interpret scikit's learn confusion matrix and classification report?
- Amazon Machine Learning for sentiment analysis
- What Machine Learning algorithm would be appropriate?
- LDA generated topics
- Spectral clustering with Similarity matrix constructed by jaccard coefficient
- Speeding up Viterbi execution
- Memory Error with Classifier fit and partial_fit
- How to find algo type(regression,classification) in Caret in R for all algos at once?
- Difference between weka tool's correlation coefficient and scikit learn's coefficient of determination score
- What are the approaches to the Big-Data problems?
Related Questions in PYTORCH
- Pytorch install with anaconda error
- How should I save the model of PyTorch if I want it loadable by OpenCV dnn module
- PyTorch: memorize output from several layers of sequencial
- in Pytorch, restore the model parameters but the same initial loss
- Seq2seq pytorch Inference slow
- Why does autograd not produce gradient for intermediate variables?
- pytorch inception model outputs the wrong label for every input image
- "expected CPU tensor(got CUDA tensor)" error for PyTorch
- Float16 (HalfTensor) in pytorch + cuda
- Access parameter names in torch
- Efficient way of calculating sum of unequal sized chunks of tensor in Pytorch
- what is the equivalent of theano.tensor.clip in pytorch?
- How can I do scatter and gather operations in NumPy?
- How do I write a PyTorch sequential model?
- How to combine multiple models together?
Related Questions in ATTENTION-MODEL
- Extracting attention matrix with TensorFlow's seq2seq example code during decoding
- Multiple issues with axes while implementing a Seq2Seq with attention in CNTK
- Getting Cuda Out of Memory while running Longformer Model in Google Colab. Similar code using Bert is working fine
- AttentionQKV from Trax
- AttributeError: can't set attribute. Hierarchical Attentional Network
- how does nn.embedding for developing an encoder-decoder model works?
- Visualizing self attention weights for sequence addition problem with LSTM?
- how does the BertModel know to skip attention_mask argument when applied to a single sentence?
- Tensorflow model weights are not saving completely
- How can I add tf.keras.layers.AdditiveAttention in my model?
- (Efficiently) expanding a feature mask tensor to match embedding dimensions
- Self attention and multi input model in tensorflow
- Why is my attention model worse than non-attention model
- Is it possible to increase the attention scores for a part of a sequence for Transformer models?
- How to get padding mask for cross attention of decoder of transformer
Related Questions in SEQ2SEQ
- Does using FP16 help accelerate generation? (HuggingFace BART)
- how does nn.embedding for developing an encoder-decoder model works?
- why seq2seq model return negative loss if I used a pre-trained embedding model
- Is there a way for a closed domain chatbot to build using seq2seq, generative modeling or other methods like RNNs?
- Temporal Fusion Transformer model training encountered Gradient Vanishing
- Training a transformer to copy sequence to identical sequence?
- tensorflow multivariable seq 2 seq model return only lagged forcast
- Error: Invalid argument: ConcatOp : Dimensions of inputs should match
- Transforming keras model output during training and use multiple losses
- LSTM seq2seq input and output with different number of time steps
- predict sequence of tuples using Transformer model
- How does the finetune on transformer (t5) work?
- ValueError: Shapes (None, 16) and (None, 16, 16) are incompatible (LSTMs)
- How to translate my own sentence using Attention mechanism?
- how to create a seq2seq NLP model based on a transformer with BERT as the encoder?
Related Questions in ENCODER-DECODER
- An error was encountered when setting batch_size to 1 in sequence_to_sequence_implementation.ipynb(when batch_size > 1,it 's ok)
- Appropriate loss function in pytorch when output is an array of float numbers
- how does nn.embedding for developing an encoder-decoder model works?
- ValueError: Layer lstm_3 expects 35 inputs, but it received 3 input tensors
- Is the encoder in decoder = LSTM(128)(encoder) the hidden state or the input to the decoder?
- Why is my attention model worse than non-attention model
- How to get padding mask for cross attention of decoder of transformer
- Decoder error not supported error when render 360 video on web application
- Problem with Sending Logon Message Using SBE Over a Socket in Java
- creating an encoder-decoder LSTM model for text samarization in tensorflow
- TensorFlow Callback loss monitor not retrieving the loss for training data
- RNN Encoder Decoder Model generates empty Output
- Error while generating dimension of universal sentence encoder embedding
- Encoder-Decoder for Trajectory Prediction
- How to train an encoder-decoder model?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Answering the last bit first: Yes, we do need
Embeddingor an equivalent. At least when dealing with discrete inputs (e.g. letters or words of a language), because these tokens come encoded as integers (e.g. 'a' -> 1, 'b' -> 2, etc.), but those numbers do not carry meaning: The letter 'b' is not "like 'a', but more", which its original encoding would suggest. So we provide theEmbeddingso that the network can learn how to represent these letters by something useful, e.g. making vowels similar to one another in some way.During the initialization, the embedding vector are sampled randomly, in the same fashion as other weights in the model, and also get optimized with the rest of the model. It is also possible to initialize them from some pretrained embeddings (e.g. from word2vec, Glove, FastText), but caution must then be exercised not to destroy them by backprop through randomly initialized model.
Embeddings are not stricly necessary, but it would be very wasteful to force network to learn that 13314 ('items') is very similar to 89137 ('values'), but completely different to 13315 ('japan'). And it would probably not even remotely converge anyway.