samedi 1 septembre 2018

Numpy random functions create inconsistent shapes for given argument

I found an odd behavior of numpy's random number generators. It seems that they do not generate consistent matrix shapes for a given argument. It is just super annoying to spend an extra line for conversion afterward which I'd like to circumvent. How can I tell matlib.randn directly to generate a vector of size (200,)?

import numpy as np
A = np.zeros((200,))
B = np.matlib.randn((200,))
print(A.shape)    # prints (200,)
print(B.shape)    # prints (1, 200)




Aucun commentaire:

Enregistrer un commentaire