美文网首页
numpy: np.newaxis

numpy: np.newaxis

作者: 贝伟强 | 来源:发表于2017-05-15 17:07 被阅读0次

    用于增加array的dimension
    比如:
    1D 会变成 2D,2D会变成3D……

    x1 = np.array([1, 2, 3])
    np.shape(x1)  # (3,)
    
    x2 = x1[:, np.newaxis]
    np.shape(x2) # (3, 1)
    x3 = x1[np.newaxis, :]
    np.shape(x3) # (1, 3)
    

    未完

    相关文章

      网友评论

          本文标题:numpy: np.newaxis

          本文链接:https://www.haomeiwen.com/subject/hhvhxxtx.html