用法:
mxnet.ndarray.Convolution(data=None, weight=None, bias=None, kernel=_Null, stride=_Null, dilate=_Null, pad=_Null, num_filter=_Null, num_group=_Null, workspace=_Null, no_bias=_Null, cudnn_tune=_Null, cudnn_off=_Null, layout=_Null, out=None, name=None, **kwargs)
- data:(
NDArray
) - 將數據輸入到 ConvolutionOp。 - weight:(
NDArray
) - 權重矩陣。 - bias:(
NDArray
) - 偏置參數。 - kernel:(
Shape
(
tuple
)
,
required
) - 卷積核大小:(w,), (h, w) 或 (d, h, w) - stride:(
Shape
(
tuple
)
,
optional
,
default=
[
]
) - 卷積步幅:(w,)、(h, w) 或 (d, h, w)。每個維度默認為 1。 - dilate:(
Shape
(
tuple
)
,
optional
,
default=
[
]
) - 卷積膨脹:(w,)、(h, w) 或 (d, h, w)。每個維度默認為 1。 - pad:(
Shape
(
tuple
)
,
optional
,
default=
[
]
) - 卷積的零填充:(w,)、(h, w) 或 (d, h, w)。默認為無填充。 - num_filter:(
int
(
non-negative
)
,
required
) - 卷積濾波器(通道)編號 - num_group:(
int
(
non-negative
)
,
optional
,
default=1
) - 組分區數。 - workspace:(
long
(
non-negative
)
,
optional
,
default=1024
) - 卷積中允許的最大臨時工作空間 (MB)。此參數有兩種用法。當不使用 CUDNN 時,它決定了卷積核的有效批大小。當使用 CUDNN 時,它控製用於調整最佳 CUDNN 內核的最大臨時存儲空間limited_workspace
使用策略。 - no_bias:(
boolean
,
optional
,
default=0
) - 是否禁用偏差參數。 - cudnn_tune:(
{None
,
'fastest'
,
'limited_workspace'
,
'off'}
,
optional
,
default='None'
) - 是否通過運行性能測試來選擇卷積算法。 - cudnn_off:(
boolean
,
optional
,
default=0
) - 關閉此層的 cudnn。 - layout:(
{None
,
'NCDHW'
,
'NCHW'
,
'NCW'
,
'NDHWC'
,
'NHWC'}
,
optional
,
default='None'
) - 設置輸入、輸出和權重的布局。默認布局為空:NCW 表示 1d,NCHW 表示 2d,NCDHW 表示 3d。NHWC 和 NDHWC 僅在 GPU 上支持。 - out:(
NDArray
,
optional
) - 輸出 NDArray 來保存結果。
- data:(
out:- 此函數的輸出。
NDArray 或 NDArray 列表
參數:
返回:
返回類型:
在
(N+2)
-D 輸入上計算N
-D 卷積。在二維卷積中,給定形狀為
(batch_size, channel, height, width)
的輸入數據,輸出由下式計算其中 是二維互相關算子。
對於一般的二維卷積,形狀是
- data:
(batch_size, channel, height, width)
- weight:
(num_filter, channel, kernel[0], kernel[1])
- bias:
(num_filter,)
- out:
(batch_size, num_filter, out_height, out_width)
.
定義:
f(x,k,p,s,d) = floor((x+2*p-d*(k-1)-1)/s)+1
那麽我們有:
out_height=f(height, kernel[0], pad[0], stride[0], dilate[0]) out_width=f(width, kernel[1], pad[1], stride[1], dilate[1])
如果
no_bias
設置為 true,則忽略bias
項。默認數據
layout
為NCHW
,即(batch_size, channel, height, width)
。我們可以選擇其他布局,例如NWC
。如果
num_group
大於 1,用g
表示,則將輸入data
沿通道軸均勻拆分為g
部分,並沿第一維均勻拆分weight
。接下來計算i
-th 數據部分與i
-th 權重部分的卷積。通過連接所有g
結果獲得輸出。一維卷積沒有
height
維度,但在空間中隻有width
。- data:
(batch_size, channel, width)
- weight:
(num_filter, channel, kernel[0])
- bias:
(num_filter,)
- out:
(batch_size, num_filter, out_width)
.
除了
height
和width
之外,3-D 卷積還增加了一個額外的depth
維度。形狀是- data:
(batch_size, channel, depth, height, width)
- weight:
(num_filter, channel, kernel[0], kernel[1], kernel[2])
- bias:
(num_filter,)
- out:
(batch_size, num_filter, out_depth, out_height, out_width)
.
weight
和bias
都是可學習的參數。還有其他選項可以調整性能。
- cudnn_tune:啟用此選項會導致更長的啟動時間,但可能會提供更快的速度。選項是
- off: 沒有調
- limited_workspace:運行測試並選擇不超過工作空間限製的最快算法。
- fastest:選擇最快的算法並忽略工作空間限製。
- None(默認):行為由環境變量決定
MXNET_CUDNN_AUTOTUNE_DEFAULT
. 0 表示關閉,1 表示有限工作空間(默認),2 表示最快。
- workspace:大量會導致更多(GPU)內存使用,但可能會提高性能。
相關用法
- Python mxnet.ndarray.Concat用法及代碼示例
- Python mxnet.ndarray.Cast用法及代碼示例
- Python mxnet.ndarray.Custom用法及代碼示例
- Python mxnet.ndarray.op.uniform用法及代碼示例
- Python mxnet.ndarray.op.sample_negative_binomial用法及代碼示例
- Python mxnet.ndarray.NDArray.ndim用法及代碼示例
- Python mxnet.ndarray.op.khatri_rao用法及代碼示例
- Python mxnet.ndarray.op.unravel_index用法及代碼示例
- Python mxnet.ndarray.contrib.group_adagrad_update用法及代碼示例
- Python mxnet.ndarray.op.slice_like用法及代碼示例
- Python mxnet.ndarray.sparse.trunc用法及代碼示例
- Python mxnet.ndarray.op.L2Normalization用法及代碼示例
- Python mxnet.ndarray.op.softmax_cross_entropy用法及代碼示例
- Python mxnet.ndarray.where用法及代碼示例
- Python mxnet.ndarray.NDArray.reshape用法及代碼示例
- Python mxnet.ndarray.op.round用法及代碼示例
- Python mxnet.ndarray.SliceChannel用法及代碼示例
- Python mxnet.ndarray.eye用法及代碼示例
- Python mxnet.ndarray.sample_multinomial用法及代碼示例
- Python mxnet.ndarray.op.diag用法及代碼示例
- Python mxnet.ndarray.ones_like用法及代碼示例
- Python mxnet.ndarray.linalg_gemm用法及代碼示例
- Python mxnet.ndarray.stop_gradient用法及代碼示例
- Python mxnet.ndarray.op.linalg_det用法及代碼示例
- Python mxnet.ndarray.argmin用法及代碼示例
注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 mxnet.ndarray.Convolution。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。