如何使用numpy random创建具有随机数据的四维数组。

huangapple go评论54阅读模式
英文:

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

问题

我的模型接受形状为(1, 32, 32, 3)的数据,我正在寻找一种使用numpy中的np.array传递数据的方法。请帮忙,将不胜感激。

英文:

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

答案1

得分: 2

您目前的数据是一维数组,您想将输入数据转换为一个四维数组吗?因为四维数组是矩阵的矩阵,您现在的数据输入看起来像是较大矩阵中的一个矩阵的单一索引。要创建一个四维数组,只需执行以下操作:

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

要获得更好的结果,我们需要了解您数据的结构。

英文:

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

huangapple
  • 本文由 发表于 2023年6月5日 23:03:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76407741.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定