Issue
I have a tensor, t
, of the following shape: torch.Size([280, 4, 768])
.
What I want is to achieve, effectively, concatenation along the second axis, resulting in torch.Size([280, 3072])
.
I know that I can for instance, do:
torch.cat((x[:, -4, :], x[:, -3, :], x[:, -2, :], x[:, -1, :]), dim=1)
but is there a nicer way of writing this?
How do I achieve reshaping along the second axis without messing up my values?
Solution
Yes you can apply a straight forward reshape
:
>>> x.reshape(len(x), -1)
Answered By - Ivan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.