pythonnumpynumpy-ndarrayn-dimensional

Turning a 6 value 1 dimensional numpy.ndarray into a 6 dimensional


I have a numpy ndarray with 6 values in 1 dim. These 6 values represent a point in 6 dimensions. How do I convert it in numpy to get a 6d array?

Backstory: I need this 6d layout for my neural network. The training happend with 6d data. For making predicitons I fail to reshape the data.


Solution

  • Here, is the solution of your requirement which you mentioned above in comments, but important thing to understand is (6,) is not a 6-dimensional array. It's an array of shape (6, ) is 1-dimensional and consists of 6 elements.

    import numpy as np 
    x = np.array([1,2,3,4,5,6]) 
    x = np.reshape(a, (6,))
    print(x.shape)
    

    Output:

    (6,)

    print(x)
    

    Output:

    [1 2 3 4 5 6]