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
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))
2 Comments
amg
Thanks, I tried this but I got this error " ValueError: setting an array element with a sequence "
George V Jose
Ok. It means that some of the elements of the array are missing. Make sure that array is complete before reshaping.