本文整理汇总了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