Search code examples
pythonnumpytritonserver

How to create 4d array with random data using numpy random


My model accepts data in the shape(1, 32, 32, 3), I am looking for a way to pass the data using np.array from numpy. Any help on this will be appreciated please


Solution

  • Your data right now is a one-dimensional array you want to convert your input data to a 4-dimensional array? Because a 4d array is a matrice of matrices the data input you have right now looks like a singular index within a matrix of the bigger matrix of matrixes. to create a 4d array it just:

    a = np.random.rand(1, 32, 32, 3)
    

    to get something better we need the structure of your data