Git Product home page Git Product logo

Comments (6)

szagoruyko avatar szagoruyko commented on July 21, 2024 9

Your understanding is correct. The first decoder self attention does not receive any data dependent inputs, so we pass zeros as inputs. It could be removed to save some parameters and compute, but we keep for simplicity.

We should add a comment explaining this in the code.

from detr.

rardz avatar rardz commented on July 21, 2024

Your understanding is correct. The first decoder self attention does not receive any data dependent inputs, so we pass zeros as inputs. It could be removed to save some parameters and compute, but we keep for simplicity.

We should add a comment explaining this in the code.

As a matter of fact, not only in the first decoderlayer, but also all the subsquent layers, the self attention part can be skipped actually. Your choice is the 3-sublayered version, a little strange because such 3-sublayered decoder are more used in autogressive tasks like seq2seq. A 3-sublayered decoder will give a better performance?

from detr.

szagoruyko avatar szagoruyko commented on July 21, 2024

no, in subsequent layers self attention has meaningful data dependent inputs and needed for communication, so can't be skipped.

from detr.

rardz avatar rardz commented on July 21, 2024

OK, never mind for my wrong understanding.

from detr.

fmassa avatar fmassa commented on July 21, 2024

Hi,

I believe we have answered your question, and as such I'm closing the issue, but let us know if you have any further questions.

from detr.

zachluo avatar zachluo commented on July 21, 2024

@rardz @szagoruyko

tgt2 = self.self_attn(q, k, value=tgt2, attn_mask=tgt_mask, key_padding_mask=tgt_key_padding_mask)[0]

https://pytorch.org/docs/stable/_modules/torch/nn/modules/activation.html#MultiheadAttention

Here self_attn will add a projection layer with learnable bias on q, k, and v. Though the tgt2 is a zero tensor at the first layer, it will still hold non-zero values.

from detr.

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.