gpt4 book ai didi

python - np.array 的裁剪部分

转载 作者:太空狗 更新时间:2023-10-30 01:53:57 25 4
gpt4 key购买 nike

我有一个类似 numpy 的数组 A

A.shape
(512,270,1,20)

我不想使用维度 4 中的所有 20 层。新数组应该是这样的

Anew.shape
(512,270,1,2)

所以我想裁剪出数组 A 的 2 个“切片”

最佳答案

来自 the python documentation ,答案是:

start = 4 # Index where you want to start.
Anew = A[:,:,:,start:start+2]

关于python - np.array 的裁剪部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33232507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com