Creating an array by tiling another array

An alternative to repeat() is the tile() function, which is used to copy a whole array into a tiled pattern. For example, let's try the following:

x = np.array([[1,2],[3,4]])
y = np.tile(x,(2,3))

This will take the array x and repeat it twice along axis 0, and then repeat the resulting array three times along axis 1. The result is a 2 x 3 tiling of the input array, as shown in the following output:

array([[1, 2, 1, 2, 1, 2],
[3, 4, 3, 4, 3, 4],
[1, 2, 1, 2, 1, 2],
[3, 4, 3, 4, 3, 4]])
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset