Git Product home page Git Product logo

Comments (6)

michaelauli avatar michaelauli commented on May 12, 2024 1

Those values worked well based on cross validation experiments.

from fairseq.

xvshiting avatar xvshiting commented on May 12, 2024

为什么要乘这个数?

from fairseq.

xvshiting avatar xvshiting commented on May 12, 2024

That multiple may enlarge the value of both words and positional embedding Matrix.

from fairseq.

Zrachel avatar Zrachel commented on May 12, 2024

这大哥。。。我还以为author不睡觉回复这么快。。。
我知道会enlarge值域,但是后面应该怎么调呢?我想知道该加layer_norm还是咋地。

About why multiply sqrt(512).

Explain: I'm testing position encoding from transformer on fairseq-py. Here is my result:

Experiment 1: x = embed(tokens) * sqrt(512) + position encoding ---- loss exploding
Experiment 2: x = embed(tokens) + position encoding/sqrt(512) ---- loss decreases normal
Experiment 3: x = embed(tokens) * sqrt(512)----loss exploding
Experiment 4: x = embed(tokens) + position encoding ---- loss exploding

It's obviously the range problem.

from fairseq.

michaelauli avatar michaelauli commented on May 12, 2024

Yes, you are changing the range of the embeddings which is the problem. If you want a fixed encoding for the positions, then try to set it so that the range of the position encoding is similar to how nn.Embedding is initialized, i.e., similar to normal(0, 0.1). Also, you may want to use a custom layer instead of nn.Embedding which simply outputs those fixed position features.

from fairseq.

Zrachel avatar Zrachel commented on May 12, 2024

Thank you. Is there any explanation on why input should be in a small range (normal(0, 0.1)) instead of normal(0, 1)?

from fairseq.

Related Issues (20)

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.