python(14)-numpy.linspace,.vstack,.random.uniform

Numpy commonly used functions


This blog post summarizes some of the major programming numpy functions encountered in the process

1 np.linspace ()

And the like between the output (-1, 1) the number of pitch 15

np.linspace (-1, 1, 15)

2 np.vstack ()

For loop on one line, each line of the stack 15 as the number of 64, to generate a matrix of 64 * 15

np.vstack([np.linspace(-1, 1, 15) for _ in range(64)])

3 np.random.uniform()

64 data randomly sampled from a uniform distribution [1,2], and the size conversion by the (64) to (64, 1)

np.random.uniform(1, 2, size=64)[:, np.newaxis]

Guess you like

Origin blog.csdn.net/sinat_40624829/article/details/91127405