5

I have a 4d array of shape like this. It has total 18*100 = 1800 rows and 30 dimensional outputs per row

(18, 100, 30, 1, 1)

i want to convert or reshape this into 2d array, the easiest way

(1800,30)

Sorry for being so naive with numpy, but please i am a novice user. Any help much appreciated.

0

2 Answers 2

10
numpy.reshape(input_in_4D, (1800,30))

Of course this just converts the input in the default order (meaning you "unroll" the input array from inner to outer); if you need special ordering, you should read up on slicing.

Sign up to request clarification or add additional context in comments.

2 Comments

I understand this is pseudo code, but python does not accept variables that start with numbers. Also, this is not a valid input syntax for reshape it should be np.reshape(input_4d, (1800, 3)) or the more popular input_4d.reshape(1800,3).
it should be: np.reshape(input_4d, (1800, 30)) (I mean thirty not three).
3

You can use reshape method:

newArray = oldArray.reshape(1800,30)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.