Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross attention issue, topic_12.3. Attention and the Transformer #838

Open
omniaalwazzan opened this issue Jan 25, 2023 · 3 comments
Open

Comments

@omniaalwazzan
Copy link

Thanks a lot for this valuable repository

I have a question regarding cross attention presented in the topic 12.3. Attention and the Transformer.

Is this line working properly d_xq, d_xk, d_xv = d_input

In my case, it doesn't work.

Thanks,
Omnia

@Atcold
Copy link
Owner

Atcold commented May 17, 2023

What does it mean "it doesn't work"?
Is it issuing some error to you?

@omniaalwazzan
Copy link
Author

Thanks a lot for replying @Atcold. I am sorry I was quite busy with some deadlines for my PhD.

Sorry for the confusion, you are right, I should have mentioned the error, so the error is in this line:
d_xq, d_xk, d_xv = d_input TypeError: cannot unpack non-iterable int object

When I pass d_input to use cross-attention.

As far as I understand when we want to initialize or assign a value/integer to multiple variables we need unpacked these values as the int object has no iter method, so maybe to fix that line causing the error, we do this instead:
d_xq, d_xk, d_xv = d_input, d_input, d_input

However, when I do the mentioned solution, I get the same result of self-attention, is this possible? I think the result should be slightly different according to the cross-attention definition. Please feel free to correct me at any point, I have far less experience than you :)

@Atcold
Copy link
Owner

Atcold commented Aug 23, 2023

d_input is a tuple of 3 elements specifying the dimension d for query, key, and values.
This functionality is not used in 15-transformer.ipynb, so I'm confused about where you're getting the error.
Could you explain to me what you're doing so I can help you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants