zoukankan      html  css  js  c++  java
  • python数组array的transpose方法

    import cv2
    import imageio
    import matplotlib.pyplot as plt
    import numpy as npif __name__ == '__main__':
        temp0 = np.array([[[[0.], [1.]], [[0.], [1.]], [[0.], [1.]], [[0.], [1.]]],
                          [[[0.], [1.]], [[0.], [1.]], [[0.], [1.]], [[0.], [1.]]],
                          [[[0.], [1.]], [[0.], [1.]], [[0.], [1.]], [[0.], [1.]]],
                          [[[0.], [1.]], [[0.], [1.]], [[0.], [1.]], [[0.], [1.]]]])
        temp1 = temp0.transpose(2, 0, 1, 3)
        temp2 = np.array([[[[0.], [0.], [0.], [0.]],
                          [[0.], [0.], [0.], [0.]],
                          [[0.], [0.], [0.], [0.]],
                          [[0.], [0.], [0.], [0.]]],
                         [[[1.], [1.], [1.], [1.]],
                          [[1.], [1.], [1.], [1.]],
                          [[1.], [1.], [1.], [1.]],
                          [[1.], [1.], [1.], [1.]]]])
        print((temp1 == temp2).all())
        print(temp0.shape)
        print(temp1.shape)
        print(temp2.shape)
  • 相关阅读:
    JS-07 (js的面向对象编程)
    AI SiameseFC
    phpstorm调试
    Php 编译扩展
    canvas
    AI FCN
    AI WebGL
    Python flask
    JIT 即时编译
    小程序
  • 原文地址:https://www.cnblogs.com/iuyy/p/14058184.html
Copyright © 2011-2022 走看看