Python mxnet.ndarray.pad() Examples

The following are 16 code examples of mxnet.ndarray.pad(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module mxnet.ndarray , or try the search function .
Example #1
Source File: net.py    From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 5 votes vote down vote up
def forward(self, x):
        return F.pad(x, mode='reflect', pad_width=self.pad_width) 
Example #2
Source File: net.py    From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 5 votes vote down vote up
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) 
Example #3
Source File: net.py    From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 5 votes vote down vote up
def forward(self, x):
        x = self.pad(x)
        out = self.conv2d(x)
        return out 
Example #4
Source File: irevnet.py    From imgclsmob with MIT License 5 votes vote down vote up
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 
Example #5
Source File: irevnet.py    From imgclsmob with MIT License 5 votes vote down vote up
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) 
Example #6
Source File: irevnet.py    From imgclsmob with MIT License 5 votes vote down vote up
def hybrid_forward(self, F, x1, x2):
        if self.do_padding:
            x = F.concat(x1, x2, dim=1)
            x = self.pad(x)
            x1, x2 = F.split(x, axis=1, num_outputs=2)
        fx2 = self.bottleneck(x2)
        if self.do_downscale:
            x1 = self.psi(x1)
            x2 = self.psi(x2)
        y1 = fx2 + x1
        return x2, y1 
Example #7
Source File: irevnet.py    From imgclsmob with MIT License 5 votes vote down vote up
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 
Example #8
Source File: net.py    From training_results_v0.6 with Apache License 2.0 5 votes vote down vote up
def forward(self, x):
        return F.pad(x, mode='reflect', pad_width=self.pad_width) 
Example #9
Source File: net.py    From training_results_v0.6 with Apache License 2.0 5 votes vote down vote up
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) 
Example #10
Source File: net.py    From training_results_v0.6 with Apache License 2.0 5 votes vote down vote up
def forward(self, x):
        x = self.pad(x)
        out = self.conv2d(x)
        return out 
Example #11
Source File: net.py    From MXNet-Gluon-Style-Transfer with MIT License 5 votes vote down vote up
def forward(self, x):
        return F.pad(x, mode='reflect', pad_width=self.pad_width) 
Example #12
Source File: net.py    From MXNet-Gluon-Style-Transfer with MIT License 5 votes vote down vote up
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) 
Example #13
Source File: net.py    From MXNet-Gluon-Style-Transfer with MIT License 5 votes vote down vote up
def forward(self, x):
        x = self.pad(x)
        out = self.conv2d(x)
        return out 
Example #14
Source File: net.py    From SNIPER-mxnet with Apache License 2.0 5 votes vote down vote up
def forward(self, x):
        return F.pad(x, mode='reflect', pad_width=self.pad_width) 
Example #15
Source File: net.py    From SNIPER-mxnet with Apache License 2.0 5 votes vote down vote up
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) 
Example #16
Source File: net.py    From SNIPER-mxnet with Apache License 2.0 5 votes vote down vote up
def forward(self, x):
        x = self.pad(x)
        out = self.conv2d(x)
        return out