0

I want to ask about how I reshape an array with a different number of elements, For example, the size of the array is (1000,). I want to reshape it to be (1000, None,None,1) to be the input to CNN, I'm using keras.

1 Answer 1

1

I don't think 'None' can be accepted in any reshape function. Reshape functions usually require numeric size. But you can reshape 'None' part to 1 to fit the model you are using.
For reshaping,
considering x is the variable that needs to be reshaped,

  • Using Numpy,
    x = np.reshape(x, (1000, 1, 1, 1))
  • Using Tensorflow,
    x = tf.reshape(x, (1000, 1, 1, 1))
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I tried this but I got this error " ValueError: setting an array element with a sequence "
Ok. It means that some of the elements of the array are missing. Make sure that array is complete before reshaping.

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.