用标准正态分布创建随意的形状:
import random
import numpy as np
test1 = np.random.randn()
test2 = np.random.randn(5)
test3 = np.random.randn(1,5)
test4 = np.random.randn(5,1)
Screen Shot 2018-09-01 at 12.49.05 AM.png
这里介绍一个有用的变形函数:np.newaxis
test2[np.newaxis, :] # equals to test3, shape = 1*5
test2[:,np.newaxis] # # equals to test4, shape = 1*5
网友评论