I have two numpy arrays of sizes: [20,3,100,100] and [20,5,100,100].
They are 20 (100,100) images with 3 channels, and 5 channels, respectively. I want to concatenate the channels so that I have 20 (100,100) images with 8 channels. I would like to concat them along (dim = 1) them together, without having to create a new numpy.zeros
array of size [20,8,100,100]. Is this possible?
Concatenate merges arrays along an existing axis:
import numpy as np
a = np.zeros((20,3,100,100))
b = np.ones((20,5,100,100))
output = np.concatenate((a,b), axis=1)
output.shape
# (20, 8, 100, 100)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.