How/What to initialize the hidden states in RNN sequence-to-sequence models?2019 Community Moderator ElectionWhy do we need to add START <s> + END </s> symbols when using Recurrent Neural Nets for Sequence-to-Sequence Models?How to train the same RNN over multiple series?What is the use of torch.no_grad in pytorch?What are the benefits and tradeoffs of a 1D conv vs a multi-input seq2seq LSTM model?On-the-fly seq2seq: starting translation before the input sequence endsCan Sequence to sequence models be used to convert code from one programming language to another?How many Hidden Layers and Neurons should I use in an RNN?What is the advantage of using RNN with fixed timestep length over Neural Network?What should the size of the decoder output be in a sequence to sequence modelInitialising states in a multilayer sequence to sequence model

One verb to replace 'be a member of' a club

Is Mindfulness the Opposite of Multitasking?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

Unlock My Phone! February 2018

How dangerous is XSS

Two tailed t test for two companies' monthly profits

What's the meaning of "Sollensaussagen"?

Explaination of a justification: additive functors preserve limits

files created then deleted at every second in tmp directory

In Bayesian inference, why are some terms dropped from the posterior predictive?

How seriously should I take size and weight limits of hand luggage?

Is this draw by repetition?

Rotate ASCII Art by 45 Degrees

Detention in 1997

What exactly is ineptocracy?

What is a Samsaran Word™?

Fair gambler's ruin problem intuition

what's the precise name of command, 'shift + r'?

How can a day be of 24 hours?

Why were 5.25" floppy drives cheaper than 8"?

How to stretch the corners of this image so that it looks like a perfect rectangle?

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

Can someone clarify Hamming's notion of important problems in relation to modern academia?

Expand and Contract



How/What to initialize the hidden states in RNN sequence-to-sequence models?



2019 Community Moderator ElectionWhy do we need to add START <s> + END </s> symbols when using Recurrent Neural Nets for Sequence-to-Sequence Models?How to train the same RNN over multiple series?What is the use of torch.no_grad in pytorch?What are the benefits and tradeoffs of a 1D conv vs a multi-input seq2seq LSTM model?On-the-fly seq2seq: starting translation before the input sequence endsCan Sequence to sequence models be used to convert code from one programming language to another?How many Hidden Layers and Neurons should I use in an RNN?What is the advantage of using RNN with fixed timestep length over Neural Network?What should the size of the decoder output be in a sequence to sequence modelInitialising states in a multilayer sequence to sequence model










3












$begingroup$


In an RNN sequence-to-sequence model, the encode input hidden states and the output's hidden states needs to be initialized before training.



What values should we initialize them with? How should we initialize them?



From the PyTorch tutorial, it simply initializes zeros to the hidden states.



Is initializing zero the usual way of initializing hidden states in RNN seq2seq networks?



How about glorot initialization?



For a single-layer vanilla RNN wouldn't the fan-in and fan-out be equals to $(1 + 1)$ which gives a variance of $1$ and the gaussian distribution with $mean=0$ gives us a uniform distribution of $0$s.



for-each input-hidden weight
variance = 2.0 / (fan-in +fan-out)
stddev = sqrt(variance)
weight = gaussian(mean=0.0, stddev)
end-for


For single layer encoder-decoder architecture with attention, if we use glorot, we'll get a very very small variance when initializing the decoder hidden state since the fan-in would include the attention which is mapped to all possible vocabulary from the encoder output. So we result in a gaussian mean of ~= 0 too since stdev is really really small.



What other initialization methods are there, esp. for the use on RNN seq2seq models?










share|improve this question











$endgroup$
















    3












    $begingroup$


    In an RNN sequence-to-sequence model, the encode input hidden states and the output's hidden states needs to be initialized before training.



    What values should we initialize them with? How should we initialize them?



    From the PyTorch tutorial, it simply initializes zeros to the hidden states.



    Is initializing zero the usual way of initializing hidden states in RNN seq2seq networks?



    How about glorot initialization?



    For a single-layer vanilla RNN wouldn't the fan-in and fan-out be equals to $(1 + 1)$ which gives a variance of $1$ and the gaussian distribution with $mean=0$ gives us a uniform distribution of $0$s.



    for-each input-hidden weight
    variance = 2.0 / (fan-in +fan-out)
    stddev = sqrt(variance)
    weight = gaussian(mean=0.0, stddev)
    end-for


    For single layer encoder-decoder architecture with attention, if we use glorot, we'll get a very very small variance when initializing the decoder hidden state since the fan-in would include the attention which is mapped to all possible vocabulary from the encoder output. So we result in a gaussian mean of ~= 0 too since stdev is really really small.



    What other initialization methods are there, esp. for the use on RNN seq2seq models?










    share|improve this question











    $endgroup$














      3












      3








      3


      1



      $begingroup$


      In an RNN sequence-to-sequence model, the encode input hidden states and the output's hidden states needs to be initialized before training.



      What values should we initialize them with? How should we initialize them?



      From the PyTorch tutorial, it simply initializes zeros to the hidden states.



      Is initializing zero the usual way of initializing hidden states in RNN seq2seq networks?



      How about glorot initialization?



      For a single-layer vanilla RNN wouldn't the fan-in and fan-out be equals to $(1 + 1)$ which gives a variance of $1$ and the gaussian distribution with $mean=0$ gives us a uniform distribution of $0$s.



      for-each input-hidden weight
      variance = 2.0 / (fan-in +fan-out)
      stddev = sqrt(variance)
      weight = gaussian(mean=0.0, stddev)
      end-for


      For single layer encoder-decoder architecture with attention, if we use glorot, we'll get a very very small variance when initializing the decoder hidden state since the fan-in would include the attention which is mapped to all possible vocabulary from the encoder output. So we result in a gaussian mean of ~= 0 too since stdev is really really small.



      What other initialization methods are there, esp. for the use on RNN seq2seq models?










      share|improve this question











      $endgroup$




      In an RNN sequence-to-sequence model, the encode input hidden states and the output's hidden states needs to be initialized before training.



      What values should we initialize them with? How should we initialize them?



      From the PyTorch tutorial, it simply initializes zeros to the hidden states.



      Is initializing zero the usual way of initializing hidden states in RNN seq2seq networks?



      How about glorot initialization?



      For a single-layer vanilla RNN wouldn't the fan-in and fan-out be equals to $(1 + 1)$ which gives a variance of $1$ and the gaussian distribution with $mean=0$ gives us a uniform distribution of $0$s.



      for-each input-hidden weight
      variance = 2.0 / (fan-in +fan-out)
      stddev = sqrt(variance)
      weight = gaussian(mean=0.0, stddev)
      end-for


      For single layer encoder-decoder architecture with attention, if we use glorot, we'll get a very very small variance when initializing the decoder hidden state since the fan-in would include the attention which is mapped to all possible vocabulary from the encoder output. So we result in a gaussian mean of ~= 0 too since stdev is really really small.



      What other initialization methods are there, esp. for the use on RNN seq2seq models?







      pytorch recurrent-neural-net sequence-to-sequence glorot-initialization






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 30 '18 at 6:46







      alvas

















      asked Jan 30 '18 at 6:30









      alvasalvas

      79631229




      79631229




















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          It is important to clear up the difference between hidden state initialization and weight initialization. Glotrot (Xavier), Kaiming etc. are all initialization methods for the weights of neural networks.



          Since your question is asking about hidden state initialization:
          Hidden states on the other hand can be initialized in a variety of ways, initializing to zero is indeed common. Other methods include sampling from Gaussian or other distributions. In relation to RNN's this defines what a RNN starts with as its 'memory'. Two common approaches seem to be either a noisy initialization (from some sort of distribution or a random number generator), or a learned initialization.



          To synthesize the link above; initializing hidden states with zeros can lead to the network learning to adapt from a zero hidden state, rather than minimizing the loss for a long sequence (it follows that this is more of a problem for short sequences). If there are enough sequences it can make sense to have the initial state be a trained variable that is a function of the error during back propagation.






          share|improve this answer









          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "557"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f27225%2fhow-what-to-initialize-the-hidden-states-in-rnn-sequence-to-sequence-models%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0












            $begingroup$

            It is important to clear up the difference between hidden state initialization and weight initialization. Glotrot (Xavier), Kaiming etc. are all initialization methods for the weights of neural networks.



            Since your question is asking about hidden state initialization:
            Hidden states on the other hand can be initialized in a variety of ways, initializing to zero is indeed common. Other methods include sampling from Gaussian or other distributions. In relation to RNN's this defines what a RNN starts with as its 'memory'. Two common approaches seem to be either a noisy initialization (from some sort of distribution or a random number generator), or a learned initialization.



            To synthesize the link above; initializing hidden states with zeros can lead to the network learning to adapt from a zero hidden state, rather than minimizing the loss for a long sequence (it follows that this is more of a problem for short sequences). If there are enough sequences it can make sense to have the initial state be a trained variable that is a function of the error during back propagation.






            share|improve this answer









            $endgroup$

















              0












              $begingroup$

              It is important to clear up the difference between hidden state initialization and weight initialization. Glotrot (Xavier), Kaiming etc. are all initialization methods for the weights of neural networks.



              Since your question is asking about hidden state initialization:
              Hidden states on the other hand can be initialized in a variety of ways, initializing to zero is indeed common. Other methods include sampling from Gaussian or other distributions. In relation to RNN's this defines what a RNN starts with as its 'memory'. Two common approaches seem to be either a noisy initialization (from some sort of distribution or a random number generator), or a learned initialization.



              To synthesize the link above; initializing hidden states with zeros can lead to the network learning to adapt from a zero hidden state, rather than minimizing the loss for a long sequence (it follows that this is more of a problem for short sequences). If there are enough sequences it can make sense to have the initial state be a trained variable that is a function of the error during back propagation.






              share|improve this answer









              $endgroup$















                0












                0








                0





                $begingroup$

                It is important to clear up the difference between hidden state initialization and weight initialization. Glotrot (Xavier), Kaiming etc. are all initialization methods for the weights of neural networks.



                Since your question is asking about hidden state initialization:
                Hidden states on the other hand can be initialized in a variety of ways, initializing to zero is indeed common. Other methods include sampling from Gaussian or other distributions. In relation to RNN's this defines what a RNN starts with as its 'memory'. Two common approaches seem to be either a noisy initialization (from some sort of distribution or a random number generator), or a learned initialization.



                To synthesize the link above; initializing hidden states with zeros can lead to the network learning to adapt from a zero hidden state, rather than minimizing the loss for a long sequence (it follows that this is more of a problem for short sequences). If there are enough sequences it can make sense to have the initial state be a trained variable that is a function of the error during back propagation.






                share|improve this answer









                $endgroup$



                It is important to clear up the difference between hidden state initialization and weight initialization. Glotrot (Xavier), Kaiming etc. are all initialization methods for the weights of neural networks.



                Since your question is asking about hidden state initialization:
                Hidden states on the other hand can be initialized in a variety of ways, initializing to zero is indeed common. Other methods include sampling from Gaussian or other distributions. In relation to RNN's this defines what a RNN starts with as its 'memory'. Two common approaches seem to be either a noisy initialization (from some sort of distribution or a random number generator), or a learned initialization.



                To synthesize the link above; initializing hidden states with zeros can lead to the network learning to adapt from a zero hidden state, rather than minimizing the loss for a long sequence (it follows that this is more of a problem for short sequences). If there are enough sequences it can make sense to have the initial state be a trained variable that is a function of the error during back propagation.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 17:02









                Mati KMati K

                156




                156



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Data Science Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f27225%2fhow-what-to-initialize-the-hidden-states-in-rnn-sequence-to-sequence-models%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                    Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

                    Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High