【问题标题】:can we concatenate more then two data to one tensor我们可以将两个以上的数据连接到一个张量吗
【发布时间】:2020-08-22 05:20:40
【问题描述】:

我有三个包含我的数据的 numpy 数组。

X_train = np.zeros((1, 288, 288, 3), dtype=np.uint8)

X_train2 = np.zeros((1, 288, 288, 3), dtype=np.uint8)

X_train3 = np.zeros((1, 288, 288, 3), dtype=np.uint8)

使用 np.concatenate 我可以将两个图像连接到一个张量,如下所示:

X_train2=np.concatenate([X_train, X_train2], axis = -1)

我想将多个图像 X_train 和 X_train2 和 X_train3 连接到一个张量是否可以使用 numpy。

【问题讨论】:

    标签: python numpy tensorflow keras


    【解决方案1】:

    是的。您可以根据需要连接任意数量的 numpy 数组。

    X_train_final = np.concatenate([X_train, X_train2, X_train3], axis = -1)
    

    是有效的,会给你一个数组,其中最后一个维度将是原始数组的 3 倍。您可以继续这种方式处理任意数量的数组。

    阅读文档:https://numpy.org/doc/1.18/reference/generated/numpy.concatenate.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-18
      • 2011-01-23
      • 2012-07-10
      • 2021-12-22
      • 2019-02-26
      • 2020-12-25
      相关资源
      最近更新 更多