When there is an array of two rows and three columns called gird = np.array ([[1, 2, 3, [4, 5, 6])
If you do np.concatenate ([gird, grid], axis=1), Why is the result
array([[1, 2, 3, 1, 2, 3], [4, 5, 6, 4, 5, 6] Does it work like this?
I think array([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6] I think it should be like this
python numpy concatenation
concatenate
according to the numpy document:
Join a sequence of arrays along an existing axis.
(Interpretation) Join each array along axis.
Therefore
Therefore, np.concatenate ([grid, grid], axis=1)
joins the sequence based on axis = 1. Illustrated as follows:
array ([[[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]) If you want to make a
array ([1, 2, 3, 4, 5, 6]), I think you should use stacks, not join.
flatten_grid = grid.flatten()
np.array([flatten_grid, flatten_grid])
np.stack((flatten_grid, flatten_grid))
© 2024 OneMinuteCode. All rights reserved.