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

Improved the Tensor manipulation #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ideAxel
Copy link
Collaborator

@ideAxel ideAxel commented Apr 9, 2024

Improved the Tensor manipulation in the SpatioTemporalTransformer Module.
Processed to a reshape of the data as follow : 1 Spatial_Attention b t p c -> (bt) p c 2 Temporal_Attention b t p c -> (bp) t c .

TemporalTransformer Module.
Processed to a reshape of the data.
@alexcbb
Copy link
Owner

alexcbb commented Apr 10, 2024

There is a typo in the comment l.282 : "# reshape '(b t) p c -> (b t) p c'"
It should be : "# reshape '(b t) c p -> (b t) p c'"

At line 298, x should be of size : (b t) p c so you should extract BT, P C from its shape.
To get B, you should get it from the input x of the forward I guess :

B = x.shape[0] at line 292 before prepare_tokens

Then you could replace line 298 with :

bt, P, C = x.shape

And line 299 with :

T = int(bt / B)
x = x.unflatten(0, (B, T)) # reshape '(b t) p c -> b t p c'
x =x.permute(0, 2, 1, 3) # reshape 'b t p c -> b p t c'
x =x.flatten(0, 1) # reshape 'b p t c -> (b p) t c'
Maybe I'm wrong, tell me what you think about it @ideAxel

@ideAxel
Copy link
Collaborator Author

ideAxel commented Apr 20, 2024

Hello Alex, Great take. I made a first attempt to make it work with the PatchEmbed method, we also need to adapt the interpolate_pos_encoding in the future.

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

Successfully merging this pull request may close these issues.

2 participants