python - 如何在 Python 中实现 col2im()?
问题描述
im2col
已经在 python 中有效地实现了,代码如下:
def im2col_sliding_strided(A, BSZ, stepsize=1):
# Parameters
m,n = A.shape
s0, s1 = A.strides
nrows = m-BSZ[0]+1
ncols = n-BSZ[1]+1
shp = BSZ[0],BSZ[1],nrows,ncols
strd = s0,s1,s0,s1
out_view = np.lib.stride_tricks.as_strided(A, shape=shp, strides=strd)
return out_view.reshape(BSZ[0]*BSZ[1],-1)[:,::stepsize]
它来自于在 Python 中实现 MATLAB 的 im2col 'sliding'
但它没有解决方案让列重新成像。有什么方法可以加快速度吗?
解决方案
推荐阅读
- node.js - 关闭终端或控制台后永远无法正常工作
- javascript - 如何在 React 中为嵌套对象设置状态?
- android - 更新到 gradle 6.x variant.getVariantData().getVariantConfiguration() 后,Gradle 代码损坏
- reactjs - React + flask:如何使用命令行运行 API
- node.js - 节点身份验证,当我提交凭据时没有任何反应
- python - 拆分数据帧
- reactjs - React native:如何生成与稍后将呈现的组件大小相同的空白空格?
- sql-server - Invoke-SQLCMD 无法在 PowerShell 中运行多个 SQL 语句
- python - 如何在 python 中获取基于非源代码的模块的源代码?
- python-3.x - 从 tkinter 中控制另一个应用程序