Python mxnet.gluon.nn.Conv1D() Examples
The following are 9
code examples of mxnet.gluon.nn.Conv1D().
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.gluon.nn
, or try the search function
.
Example #1
Source File: cnn.py From gluon-ts with Apache License 2.0 | 6 votes |
def __init__( self, channels: int, kernel_size: int, dilation: int = 1, activation: Optional[str] = None, **kwargs, ): super(CausalConv1D, self).__init__(**kwargs) self.dilation = dilation self.kernel_size = kernel_size self.padding = dilation * (kernel_size - 1) self.conv1d = nn.Conv1D( channels=channels, kernel_size=kernel_size, dilation=dilation, padding=self.padding, activation=activation, **kwargs, ) # noinspection PyMethodOverriding
Example #2
Source File: _network.py From gluon-ts with Apache License 2.0 | 6 votes |
def conv1d(channels, kernel_size, in_channels, use_bias=True, **kwargs): """ Conv1D with better default initialization. """ n = in_channels kernel_size = ( kernel_size if isinstance(kernel_size, list) else [kernel_size] ) for k in kernel_size: n *= k stdv = 1.0 / math.sqrt(n) winit = mx.initializer.Uniform(stdv) if use_bias: binit = mx.initializer.Uniform(stdv) else: binit = "zeros" return nn.Conv1D( channels=channels, kernel_size=kernel_size, in_channels=in_channels, use_bias=use_bias, weight_initializer=winit, bias_initializer=binit, **kwargs, )
Example #3
Source File: test_gluon.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 5 votes |
def test_conv(): layers1d = [ nn.Conv1D(16, 3, in_channels=4), nn.Conv1D(16, 3, groups=2, in_channels=4), nn.Conv1D(16, 3, strides=3, groups=2, in_channels=4), ] for layer in layers1d: check_layer_forward(layer, (1, 4, 10)) layers2d = [ nn.Conv2D(16, (3, 4), in_channels=4), nn.Conv2D(16, (5, 4), in_channels=4), nn.Conv2D(16, (3, 4), groups=2, in_channels=4), nn.Conv2D(16, (3, 4), strides=4, in_channels=4), nn.Conv2D(16, (3, 4), dilation=4, in_channels=4), nn.Conv2D(16, (3, 4), padding=4, in_channels=4), ] for layer in layers2d: check_layer_forward(layer, (1, 4, 20, 20)) layers3d = [ nn.Conv3D(16, (1, 8, 4), in_channels=4, activation='relu'), nn.Conv3D(16, (5, 4, 3), in_channels=4), nn.Conv3D(16, (3, 3, 3), groups=2, in_channels=4), nn.Conv3D(16, 4, strides=4, in_channels=4), nn.Conv3D(16, (3, 3, 3), padding=4, in_channels=4), ] for layer in layers3d: check_layer_forward(layer, (1, 4, 10, 10, 10)) layer = nn.Conv2D(16, (3, 3), layout='NHWC', in_channels=4) # check_layer_forward(layer, (1, 10, 10, 4)) layer = nn.Conv3D(16, (3, 3, 3), layout='NDHWC', in_channels=4) # check_layer_forward(layer, (1, 10, 10, 10, 4))
Example #4
Source File: prediction.py From crnn.gluon with Apache License 2.0 | 5 votes |
def __init__(self, n_class, **kwargs): super().__init__() self.fc = nn.Conv1D(channels=n_class, kernel_size=1)
Example #5
Source File: model.py From LSTNet-Gluon with Apache License 2.0 | 5 votes |
def __init__(self, num_series, conv_hid, gru_hid, skip_gru_hid, skip, ar_window): super(LSTNet, self).__init__() kernel_size = 6 dropout_rate = 0.2 self.skip = skip self.ar_window = ar_window with self.name_scope(): self.conv = nn.Conv1D(conv_hid, kernel_size=kernel_size, layout='NCW', activation='relu') self.dropout = nn.Dropout(dropout_rate) self.gru = rnn.GRU(gru_hid, layout='TNC') self.skip_gru = rnn.GRU(skip_gru_hid, layout='TNC') self.fc = nn.Dense(num_series) self.ar_fc = nn.Dense(1)
Example #6
Source File: net.py From comment_toxic_CapsuleNet with MIT License | 5 votes |
def __init__(self, **kwargs): super(FeatureBlock, self).__init__(**kwargs) self.gru = rnn.GRU(128,layout='NTC',bidirectional=True, num_layers=1, dropout=0.2) self.conv3 = nn.Conv1D(channels=128, kernel_size=5, padding=2, strides=1, activation='relu') self.conv5 = nn.Conv1D(channels=128, kernel_size=9, padding=4, strides=1, activation='relu') self.conv7 = nn.Conv1D(channels=128, kernel_size=13, padding=6, strides=1, activation='relu') self.conv_drop = nn.Dropout(0.2)
Example #7
Source File: net.py From comment_toxic_CapsuleNet with MIT License | 5 votes |
def __init__(self, **kwargs): super(FeatureBlock1, self).__init__(**kwargs) self.gru = rnn.GRU(128,layout='NTC',bidirectional=True, num_layers=1, dropout=0.2) self.conv3 = nn.Conv1D(channels=128, kernel_size=3, padding=1, strides=1, activation='relu') self.conv5 = nn.Conv1D(channels=128, kernel_size=3, padding=1, strides=1, activation='relu') self.conv7 = nn.Conv1D(channels=128, kernel_size=3, padding=1, strides=1, activation='relu') # self.gru_post_max = nn.MaxPool1D(pool_size=2) # self.gru_post_ave = nn.AvgPool1D(pool_size=2) self.gru_maxpool = nn.GlobalMaxPool1D() self.conv_maxpool = nn.GlobalMaxPool1D() ''' self.gru_avepool = nn.GlobalAvgPool1D() self.conv_avepool = nn.GlobalAvgPool1D() ''' self.conv_drop = nn.Dropout(0.5)
Example #8
Source File: cnn.py From gluon-ts with Apache License 2.0 | 5 votes |
def __init__( self, inner_channels: int, out_channels: int, kernel_size: Union[int, Tuple[int], List[int]], dilation: Union[int, Tuple[int], List[int]], **kwargs, ) -> None: super(DilatedCausalGated, self).__init__(**kwargs) with self.name_scope(): self.conv1 = CausalConv1D( channels=inner_channels, kernel_size=kernel_size, dilation=dilation, activation="tanh", ) self.conv2 = CausalConv1D( channels=inner_channels, kernel_size=kernel_size, dilation=dilation, activation="sigmoid", ) self.output_conv = gluon.nn.Conv1D( channels=out_channels, kernel_size=1 ) # noinspection PyMethodOverriding
Example #9
Source File: test_gluon.py From SNIPER-mxnet with Apache License 2.0 | 5 votes |
def test_conv(): layers1d = [ nn.Conv1D(16, 3, in_channels=4), nn.Conv1D(16, 3, groups=2, in_channels=4), nn.Conv1D(16, 3, strides=3, groups=2, in_channels=4), ] for layer in layers1d: check_layer_forward(layer, (1, 4, 10)) layers2d = [ nn.Conv2D(16, (3, 4), in_channels=4), nn.Conv2D(16, (5, 4), in_channels=4), nn.Conv2D(16, (3, 4), groups=2, in_channels=4), nn.Conv2D(16, (3, 4), strides=4, in_channels=4), nn.Conv2D(16, (3, 4), dilation=4, in_channels=4), nn.Conv2D(16, (3, 4), padding=4, in_channels=4), ] for layer in layers2d: check_layer_forward(layer, (1, 4, 20, 20)) layers3d = [ nn.Conv3D(16, (1, 8, 4), in_channels=4, activation='relu'), nn.Conv3D(16, (5, 4, 3), in_channels=4), nn.Conv3D(16, (3, 3, 3), groups=2, in_channels=4), nn.Conv3D(16, 4, strides=4, in_channels=4), nn.Conv3D(16, (3, 3, 3), padding=4, in_channels=4), ] for layer in layers3d: check_layer_forward(layer, (1, 4, 10, 10, 10)) layer = nn.Conv2D(16, (3, 3), layout='NHWC', in_channels=4) # check_layer_forward(layer, (1, 10, 10, 4)) layer = nn.Conv3D(16, (3, 3, 3), layout='NDHWC', in_channels=4) # check_layer_forward(layer, (1, 10, 10, 10, 4))