阅读源码遇到的一些Python 函数(--小白笔记)

      • npexpand_dims
      • defaultdict

np.expand_dims

扩展维度,例:

>>> import numpy
>>> a=numpy.arange(10)
>>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a.shape
(10,)
>>> b=numpy.expand_dims(a,axis=0)
>>> b
array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]])
>>> b.shape
(1, 10)
>>> b=numpy.expand_dims(a,axis=1)
>>> b
array([[0],
       [1],
       [2],
       [3],
       [4],
       [5],
       [6],
       [7],
       [8],
       [9]])
>>> b.shape
(10, 1)
>>> 

defaultdict

参考文章:http://blog.csdn.net/real_ray/article/details/17919289

你可能感兴趣的:(翻译阅读笔记,代码笔记)