MCPcopy Create free account
hub / github.com/apple/ml-pointersect / TestStackedConv1DLayers

Class TestStackedConv1DLayers

tests/cdslib/nn/modules/test_conv.py:12–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12class TestStackedConv1DLayers(unittest.TestCase):
13
14 def test_build_model1(self):
15 self.build_model(num_layer=1, dim_input=10, dim_output=5, dim_features=16,
16 kernel_sizes=3, strides=1, paddings=0, dilations=1,
17 nonlinearity='leaky_relu', add_norm_layer=True,
18 norm_fun=nn.LayerNorm, dropout_prob=0.)
19
20 def test_build_model2(self):
21 self.build_model(num_layer=4, dim_input=10, dim_output=5, dim_features=16,
22 kernel_sizes=3, strides=2, paddings=0, dilations=1,
23 nonlinearity='leaky_relu', add_norm_layer=True,
24 norm_fun=nn.LayerNorm, dropout_prob=0.)
25
26 def test_build_model3(self):
27 self.build_model(num_layer=4, dim_input=10, dim_output=5, dim_features=16,
28 kernel_sizes=3, strides=2, paddings=0, dilations=2,
29 nonlinearity='leaky_relu', add_norm_layer=True,
30 norm_fun=nn.LayerNorm, dropout_prob=0.)
31
32 def test_build_model4(self):
33 self.build_model(num_layer=4, dim_input=10, dim_output=5, dim_features=16,
34 kernel_sizes=3, strides=2, paddings=1, dilations=2,
35 nonlinearity='leaky_relu', add_norm_layer=True,
36 norm_fun=nn.LayerNorm, dropout_prob=0.)
37
38 def build_model(self, num_layer, dim_input, dim_output, dim_features,
39 kernel_sizes, strides, paddings, dilations,
40 padding_modes='zeros',
41 nonlinearity='leaky_relu', add_norm_layer=True,
42 norm_fun=nn.LayerNorm, dropout_prob=0.):
43 net = cdsnn.StackedConv1DLayers(
44 num_layers=num_layer, dim_input=dim_input, dim_output=dim_output,
45 dim_features=dim_features, kernel_sizes=kernel_sizes, strides=strides,
46 paddings=paddings, dilations=dilations,
47 nonlinearity=nonlinearity, padding_modes=padding_modes,
48 add_norm_layer=add_norm_layer, norm_fun=norm_fun,
49 dropout_prob=dropout_prob)
50
51 # print(f'num_layer: {num_layer}, dim_input: {dim_input}, dim_output: {dim_output}, '
52 # f'dim_features: {dim_features}, '
53 # f'kernel_sizes: {kernel_sizes}, '
54 # f'strides: {strides}, '
55 # f'paddings: {paddings}, '
56 # f'dilations: {dilations}, '
57 # f'padding_modes: {padding_modes}, '
58 # f'nonlinearity: {nonlinearity}, '
59 # f'add_norm_layer: {add_norm_layer}, norm_fun: {norm_fun}, dropout_prob: {dropout_prob}')
60 # print(net)
61
62 seq_len = 100
63 batch_size = 2
64 # construct input
65 x = torch.randn(seq_len, batch_size, dim_input)
66 # compute output
67 y = net(x, batch_first=False)
68
69 # compute seq_len_out

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected