
s = np.arange(0,1000)n = 5l = 10i = np.random.randint(0,len(s)-10,5)ss = np.array([s[x:x+l] for x in i])解决方法 我们可以利用基于
np.lib.stride_tricks.as_strided的 scikit-image's view_as_windows进行高效的补丁提取,就像这样 – from skimage.util.shape import vIEw_as_windows# Get slIDing windows (these are simply vIEws)w = vIEw_as_windows(s,l)# Index with indices,i for desired outputout = w[i]
相关:
NumPy Fancy Indexing – Crop different ROIs from different channels
Take N first values from every row in NumPy matrix that fulfill condition
Selecting Random Windows from Multidimensional Numpy Array Rows
总结以上是内存溢出为你收集整理的python – 如何从numpy数组中提取多个随机子序列全部内容,希望文章能够帮你解决python – 如何从numpy数组中提取多个随机子序列所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)