Write a NumPy program to split array into multiple sub-arrays along the 3rd axis.
import numpy as np print("\nOriginal arrays:") x = np.arange(16.0).reshape(2, 2, 4) print(x) new_array1 = np.dsplit(x, 2) print("\nsplit array into multiple sub-arrays along the 3rd axis:") print(new_array1)
Sample Output:
Original arrays: [[[ 0. 1. 2. 3.] [ 4. 5. 6. 7.]] [[ 8. 9. 10. 11.] [12. 13. 14. 15.]]] split array into multiple sub-arrays along the 3rd axis: [array([[[ 0., 1.], [ 4., 5.]], [[ 8., 9.], [12., 13.]]]), array([[[ 2., 3.], [ 6., 7.]], [[10., 11.], [14., 15.]]])]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer