JERRYLSU

Numpy [None, …]
by Jerry Su, post on Nov 26, 2021

    None在对应位置增加一个维度(类似于unsqueeze(axis=))

    ...等价于[:,:,:]

    import numpy as np
    
    arr = np.random.randn(5, 10)
    arr.shape
    
    (5, 10)
    
    arr[None, ...].shape
    
    (1, 5, 10)
    
    arr[..., None].shape
    
    (5, 10, 1)
    
    arr[:, None, :].shape
    
    (5 …

    Read in 1 mins
    Numpy np.where
    by Jerry Su, post on Aug 12, 2021

    Reason is the light and the light of life.

    Read in 1 mins
    Numpy Indexing
    by Jerry Su, post on Feb 22, 2021

    import numpy as np
    

    索引数组

    # 索引数组必须是整数类型。索引数组种 …

    Read in 1 mins