標籤:

np.pad

import numpy as npnndef m_images_pad(X, pad):n X_pad = np.pad(X, ((0, 0), (pad,pad), (pad,pad), (0,0)), constant)n return X_padnnnp.random.seed(1)nx = np.random.randn(4, 3, 3, 2)nx_pad = m_images_pad(x, 2)nx[1,1]nx_pad[1,1]nnnhelp(np.pad)nnp.lib.arraypad.__file__n# atom file path: see everything in the modulen# def pad is 200 lines longnnimport numpy.lib.arraypad as padndir(pad) # include everything in the modulennnp.pad # thanks to __all__ = [pad]nnp.lib.pad # thanks to __all__ = [pad]nnfrom inspect import getsourcelinesngetsourcelines(np.pad) # see source code of padnn"""n策略n- 只看當前需要的args, returnn- 其他args和用法,需要時在翻出來看n"""n

推薦閱讀:

Python 2.7安裝常用的科學計算分析包
pandas的數據結構之Series
ImagePy開發文檔 —— 常用匯總

TAG:numpy |