1

I would like to know how to correctly transpose a vector. Since my implementation does not work, apparently. Here what I do.

import numpy as np
weights = np.random.random(3)

weights.shape
(3,)

If I do the transpose:

np.transpose(weights)
np.transpose(weights).shape
(3,)

Thus, why my dimensions of weights do not change? Thank you very much.

Lucia
  • 21
  • 5
  • Thank you, Paulo. I read that post, but I cannot get its meaning or solution. Since, I think my problem is closer to this one, but still I do not know how to implement the brackets there. http://stackoverflow.com/questions/5954603/transposing-a-numpy-array – Lucia Jan 30 '17 at 14:12

1 Answers1

0
np.transpose(weights[np.newaxis])    

Or maybe, a simpler manner:

weights[np.newaxis].T

However, as pointed out in this post, you must think if you have good reasons to transpose it this way, since a transposed 1D vector is still a 1D vector.

Community
  • 1
  • 1
Paulo MiraMor
  • 1,582
  • 12
  • 30