I have done like this before:
import torch
x_train  = torch.linspace(-1, 1, 101)    # 1D tensor
print(x_train.size())
# torch.Size([101])   

x_train = x_train.view(101, 1)          # convert to 2D tensor
print(x_train.size())
# torch.Size([101, 1])