numpy.tile did not work as Matlab repmat
问题 According to What is the equivalent of MATLAB's repmat in NumPy, I tried to build 3x3x5 array from 3x3 array using python. In Matlab, this work as I expected. a = [1,1,1;1,2,1;1,1,1]; a_= repmat(a,[1,1,5]); size(a_) = 3 3 5 But for numpy.tile b = numpy.array([[1,1,1],[1,2,1],[1,1,1]]) b_ = numpy.tile(b, [1,1,5]) b_.shape = (1, 3, 15) If I want to generate the same array as in Matlab, what is the equivalent? Edit 1 The output I would expect to get is b_(:,:,1) = 1 1 1 1 2 1 1 1 1 b_(:,:,2) = 1