AI:TensorFlow张量shape

import numpy as np

if __name__ == "__main__":
    a0 = np.array([[1], [2], [3]])
    print(a0.shape)

    a1 = np.array([[1, 2, 3]])
    print(a1.shape)

    a2 = np.array([0, 1, 2])
    print(a2.shape)

    a3 = np.array([[[1, 2, 3]]])
    print(a3.shape)

    b = np.array([[1, 2, 3], [4, 5, 6]])
    print(b.shape)

    c0 = np.array([[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]])
    print(c0.shape)

    c1 = np.array([[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]]])
    print(c1.shape)

    c2 = np.array([[[1, 2, 3]], [[4, 5, 6]]])
    print(c2.shape)

    c3 = np.array([[[[1, 2, 3]], [[4, 5, 6]]]])
    print(c3.shape)

    c4 = np.array([[[1], [2], [3]], [[4], [5], [6]]])
    print(c4.shape)

输出:

(3, 1)
(1, 3)
(3,)
(1, 1, 3)
(2, 3)
(3, 3, 1)
(3, 1, 3)
(2, 1, 3)
(1, 2, 1, 3)
(2, 3, 1)
发布了1029 篇原创文章 · 获赞 987 · 访问量 336万+

猜你喜欢

转载自blog.csdn.net/zhangphil/article/details/103258034