how to concate two tensors with different dimensions in pytorch
I have two tensors in pytorch with these shapes:

torch.Size([64, 100]) and torch.Size([64, 100, 256])

I want to concate them by torch.cat but they should be in the same shape and size. So I get this error:

RuntimeError: Tensors must have same number of dimensions: got 2 and 3

what should I do to fix this problem? how can I convert 2d PyTorch tensor into 3d tensor OR how can I convert 3d PyTorch tensor to 2d tensor without losing any data? or any other idea?

Depending on what you are looking to do with those two tensors, you could consider concatenating on the last axis such that the resulting tensor is shaped (64, 100, 257). This requires you first unsqueeze a singleton dimensions on the first tensor:
&gt;&gt;&gt; x, y = torch.rand(64, 100), torch.rand(64, 100, 256)
&gt;&gt;&gt; z = torch.cat((x[..., None], y), -1)

&gt;&gt;&gt; z.shape
torch.Size([64, 100, 257])

