How to convert from a Pytroch Tensor from mathematically a column vector to a column matrix?
I am working with tensors in pytorch.
How can I convert a tensor corresponding to a column vector to a tensor corresponding to its transpose?

import numpy as np
coef = torch.from_numpy(np.arange(1.0, 5.0)).float()
print(coef)
print(coef.size())


Currently the size of coef is [4] but I want it to be [4, 1] with the same content.

It is easy to achieve in PyTorch. You can use the view() method.

coef = coef.view(4, 1)
print(coef.size()) # now the shape will be [4, 1]

