![](/img/trans.png)
[英]Reshaping a Numpy Array into lexicographical list of cubes of shape (n, n, n)
[英]Reshaping numpy (n, )
当每个列表元素包含一个2d数组时,我正在使用多个numpy对象作为numpy列表。 奇怪的是,shape()函数不能反映出这一点,只返回总体的样本数。
x_train.shape, x_test.shape, x_test.iloc[0].shape
#((22507,), (5627,), (25, 100))
这个代码片段完成了任务,但是我想知道是否有更好/麻木的方法来完成此任务。
x = []
[x.append(item) for item in x_train]
_np.array(x).shape
# (22507, 25, 100)
我已经搜索了堆栈溢出问题,尽管有很多重塑问题,但我还没有看到可以有效解决此问题的问题。
转换2D数组的1D dtype=object
数组的简单有效方法是:
np.stack(x_train)
但是首先将原始数据加载到3D数组中会更有效率。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.