本文整理匯總了Python中mxnet.ndarray.pad方法的典型用法代碼示例。如果您正苦於以下問題:Python ndarray.pad方法的具體用法?Python ndarray.pad怎麽用?Python ndarray.pad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mxnet.ndarray
的用法示例。
在下文中一共展示了ndarray.pad方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: forward
# 需要導入模塊: from mxnet import ndarray [as 別名]
# 或者: from mxnet.ndarray import pad [as 別名]
def forward(self, x):
return F.pad(x, mode='reflect', pad_width=self.pad_width)
示例2: __init__
# 需要導入模塊: from mxnet import ndarray [as 別名]
# 或者: from mxnet.ndarray import pad [as 別名]
def __init__(self, in_channels, out_channels, kernel_size, stride):
super(ConvLayer, self).__init__()
padding = int(np.floor(kernel_size / 2))
self.pad = ReflectancePadding(pad_width=(0,0,0,0,padding,padding,padding,padding))
self.conv2d = nn.Conv2D(in_channels=in_channels, channels=out_channels,
kernel_size=kernel_size, strides=(stride,stride),
padding=0)
示例3: hybrid_forward
# 需要導入模塊: from mxnet import ndarray [as 別名]
# 或者: from mxnet.ndarray import pad [as 別名]
def hybrid_forward(self, F, x):
x = x.transpose(axes=(0, 2, 1, 3))
x = F.pad(x, mode="constant", pad_width=(0, 0, 0, 0, 0, self.padding, 0, 0), constant_value=0)
x = x.transpose(axes=(0, 2, 1, 3))
return x
示例4: __init__
# 需要導入模塊: from mxnet import ndarray [as 別名]
# 或者: from mxnet.ndarray import pad [as 別名]
def __init__(self,
in_channels,
out_channels,
strides,
bn_use_global_stats,
preactivate,
**kwargs):
super(IRevUnit, self).__init__(**kwargs)
if not preactivate:
in_channels = in_channels // 2
padding = 2 * (out_channels - in_channels)
self.do_padding = (padding != 0) and (strides == 1)
self.do_downscale = (strides != 1)
with self.name_scope():
if self.do_padding:
self.pad = IRevInjectivePad(padding)
self.bottleneck = IRevBottleneck(
in_channels=in_channels,
out_channels=out_channels,
strides=strides,
bn_use_global_stats=bn_use_global_stats,
preactivate=preactivate)
if self.do_downscale:
self.psi = IRevDownscale(strides)
示例5: inverse
# 需要導入模塊: from mxnet import ndarray [as 別名]
# 或者: from mxnet.ndarray import pad [as 別名]
def inverse(self, x2, y1):
import mxnet.ndarray as F
if self.do_downscale:
x2 = self.psi.inverse(x2)
fx2 = - self.bottleneck(x2)
x1 = fx2 + y1
if self.do_downscale:
x1 = self.psi.inverse(x1)
if self.do_padding:
x = F.concat(x1, x2, dim=1)
x = self.pad.inverse(x)
x1, x2 = F.split(x, axis=1, num_outputs=2)
return x1, x2