np.random.RandState: seed, randn
01-31
import numpy as npnfrom inspect import getmodule, getsourcelinesnndef conv_single_step(a_slice_prev, W, b):n s = np.multiply(W, a_slice_prev) + bn Z = np.sum(s)nn return Znnnp.random.seed(1)na_slice_prev = np.random.randn(4, 4, 3)nW = np.random.randn(4, 4, 3)nb = np.random.randn(1, 1, 1)nZ = conv_single_step(a_slice_prev, W, b)nprint("Z =", Z)nnhelp(np.random.seed)ngetmodule(np.random.RandomState) # c codesnlen(dir(np.random.RandomState))ndir(np.random.RandomState) # found seed and random.randnnhelp(np.random.RandomState)nnhelp(np.random.randn)ndir(np.random.randn)n
推薦閱讀:
※給深度學習入門者的Python快速教程 - numpy和Matplotlib篇
※利用數組進行數據進行處理
※np ufunc: reduce, accumulate, at; np.add, multiply, sum
※數組數據類型轉換及算術運算
TAG:numpy |