zoukankan      html  css  js  c++  java
  • array , asarray, len , shape, np.squeeze , [0,0:4]

    http://blog.csdn.net/lanchunhui/article/details/55657040

    >>> g = np.array([[  40.47109199 , -10.01622954 , 275.29573762 , 311.23186909   , 0.99994779]]

    >>> print g
    [[  40.47109199  -10.01622954  275.29573762  311.23186909    0.99994779]]
    >>> len(g)
    1

    >>> g.shape
    (1, 5)

    import numpy as np
    
    x = np.array([[[0], [1], [2]]])
    print(x)
    """
    x=
    
    [[[0]
      [1]
      [2]]]
    """
    print(x.shape)  # (1, 3, 1)
    
    x1 = np.squeeze(x)  # 从数组的形状中删除单维条目,即把shape中为1的维度去掉
    
    
    print(x1)  # [0 1 2]
    print(x1.shape)  # (3,)
    
    >>> y1 = np.array([[  40.47109199 , -10.01622954 , 275.29573762 , 311.23186909  ,  0.99994779]])
    >>> y1
    array([[  40.47109199,  -10.01622954,  275.29573762,  311.23186909,
               0.99994779]])
    >>> y1[0,0:4]
    array([  40.47109199,  -10.01622954,  275.29573762,  311.23186909])
    >>> y1[0,0:0]
    array([], dtype=float64)
    >>> y1[0,0:1]
    array([ 40.47109199])
    >>> y1[0,0:5]
    array([  40.47109199,  -10.01622954,  275.29573762,  311.23186909,
              0.99994779])
  • 相关阅读:
    Frameset 框架
    FHS 文件层次标准
    history 命令
    QT基础走起
    Android中导入jar包v4的错误
    Android工具Eclipse点击卡死或者无响应情况
    让程序飞起来
    Android中报错
    【2019.9.23】NOIP2017 practice exam
    【技巧】时间复杂度
  • 原文地址:https://www.cnblogs.com/morganh/p/8522528.html
Copyright © 2011-2022 走看看