Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

repeat array along new axis

a = np.array([[1, 2], [1, 2]])
# indexing with np.newaxis inserts a new 3rd dimension, 
# which we then repeat the array along
b = np.repeat(a[:, :, np.newaxis], 3, axis=2)
print(b.shape)
# (2, 2, 3)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #repeat #array #axis
ADD COMMENT
Topic
Name
2+1 =