Question: import numpy as np x = np.array([1,2,3]) y = x[np.newaxis,:][np.newaxis,:,:] print(y.shape) Please explain why this prints out (1,1,3) and not (3,3,3) because from what I

import numpy as np x = np.array([1,2,3]) y = x[np.newaxis,:][np.newaxis,:,:] print(y.shape)

Please explain why this prints out (1,1,3) and not (3,3,3) because from what I understand, shape is like (number of arrays, rows, coloums). If I am wrong please correct me and let me know how I can understand np.shape better.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!