I'm having trouble converting a NumPy array to 1-D. I was looking for ideas that I found on SO, but the problem persists.
nu = np.reshape(np.dot(prior.T, randn(d)), -1)
print 'nu1', str(nu.shape)
print nu
nu = nu.ravel()
print 'nu2', str(nu.shape)
print nu
nu = nu.flatten()
print 'nu3', str(nu.shape)
print nu
nu = nu.reshape(d)
print 'nu4', str(nu.shape)
print nu
The code displays the following result:
nu1 (1, 200)
[[-0.0174428 -0.01855013 ... 0.01137508 0.00577147]]
nu2 (1, 200)
[[-0.0174428 -0.01855013 ... 0.01137508 0.00577147]]
nu3 (1, 200)
[[-0.0174428 -0.01855013 ... 0.01137508 0.00577147]]
nu4 (1, 200)
[[-0.0174428 -0.01855013 ... 0.01137508 0.00577147]]
What do you think, maybe the problem? What mistake am I making?
EDIT: previous (200 200), d is 200. I want to get a 1-D array: [-0.0174428 -0.01855013 ... 0.01137508 0.00577147] of size (200,). d is 200.
EDIT2: Also randn is from numpy.random (from numpy.random import randn)
Jacek source
share