python np.tile用法

import os
import sys
import numpy as np


def test():
    x = np.tile([0,1], (3, 5))
    print(x)
    y = np.random.randn(64,3,7,7)
    print(y.shape)
    z = y[:,:,:,:, np.newaxis]
    print(z.shape)
    q = np.tile(z, (1, 1, 1, 1, 7))
    print(q.shape)
    print(q[:, :, :, :, 1] == q[:, :, :, :, 5])


if __name__ == "__main__":
    print('*'*80)
    test()
    pass

默认np.tile(参数1是要扩充的实体, 参数二是沿着某个方向进行扩充)

如果在某一个方向不需要扩充, 那么那个维度上的数字就是1, 相当于没有扩充,而不是0.\

猜你喜欢

转载自blog.csdn.net/weixin_36149892/article/details/84180262