Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to glue tensors in PyTorch?
How do I glue three tensors in Pytorch
tensor()
tensor()
tensor([[16385, 2, 96, 21, 96, 21, 96]])
so that we get the following tensor:
tensor([[ 96, 20, 96, 21, 96, 960 , 577, 2, 96, 21,
96, 21, 96, 37954, 2, 96, 20, 96, 21, 96,
16385, 2, 96, 21, 96, 21, 96]])
Answer the question
In order to leave comments, you need to log in
import torch
a = torch.tensor([[ 96, 20, 96, 21, 96, 960, 577, 2, 96, 21, 96, 21, 96]])
b = torch.tensor([[37954, 2, 96, 20, 96, 21, 96]])
c = torch.tensor([[16385, 2, 96, 21, 96, 21, 96]])
torch.cat([a,b,c], 1)
###
tensor([[ 96, 20, 96, 21, 96, 960, 577, 2, 96, 21,
96, 21, 96, 37954, 2, 96, 20, 96, 21, 96,
16385, 2, 96, 21, 96, 21, 96]])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question