Coder Social home page Coder Social logo

Comments (4)

Jostarndt avatar Jostarndt commented on July 18, 2024

shared credits to @samiede

from annotated-transformer.

stanwinata avatar stanwinata commented on July 18, 2024

@Jostarndt, perhaps not, since you need 4 self.linears:

  1. linear_Q (to project query)
  2. linear_K (to project key)
  3. linear_V (to project value)
  4. linear_O (to project output)

It's true that the fourth linear is a bit more hidden, since it is located on the very top after concat as seen in the image below 😅
Screen Shot 2022-09-05 at 4 23 20 PM

from annotated-transformer.

ljmanso avatar ljmanso commented on July 18, 2024

I was looking into the issues section with the same doubt in mind and @stanwinata is right. The code is correct, just a bit obscure (I spent half an hour trying to figure it out).

When you use zip, the generator (here I mean the zip Python generator) stops with the shortest iterable. Therefore, if you zip two iterables, you will get as many items as the shortest iterable. For instance:

long_iterable = [1, 2, 3, 4]
short_iterable = ['q', 'k', 'v']
for a,b in zip(long_iterable, short_iterable):
... print(a, b)
...
1 q
2 k
3 v

from annotated-transformer.

Jostarndt avatar Jostarndt commented on July 18, 2024

Yes, I forgot to finally reply to already the first answer! You are so right, thanks for pointing out 4.!

from annotated-transformer.

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.