我们可以将两个以上的数据连接到一个张量吗 [英] can we concatenate more then two data to one tensor
问题描述
我有三个包含数据的numpy数组.
I have three numpy array that contains my data.
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,我可以将两个图像连接到一个张量,如下所示:
Using np.concatenate I can concatenate two image to one tensor as below :
X_train2=np.concatenate([X_train, X_train2], axis = -1)
我想使用numpy将多个图像X_train以及X_train2和X_train3连接到一个张量.
I want to concatenate multiple image X_train and X_train2 and X_train3 to one tensor is it possible using numpy.
推荐答案
是.您可以根据需要串联任意多个numpy数组.
Yes. You can concatenate as many numpy array as you want.
X_train_final = np.concatenate([X_train, X_train2, X_train3], axis = -1)
是有效的,它将为您提供一个数组,最后一个维度将是原始数组的3倍.您可以按照自己的喜好继续这种方式.
is valid and will give you an array where, the last dimension will be 3 times as in the original array. You can continue this way for as many arrays as you likee.
阅读文档: https://numpy.org/doc /1.18/reference/generation/numpy.concatenate.html
这篇关于我们可以将两个以上的数据连接到一个张量吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!