Example #1
0
    def test_as_matrix(self):
        from inferno.extensions.layers.reshape import AsMatrix

        input = self._get_input_variable(10, 20, 1, 1)
        as_matrix = AsMatrix()
        output = as_matrix(input)
        self.assertEqual(list(output.size()), [10, 20])
 def _make_test_model(input_channels):
     toy_net = nn.Sequential(nn.Conv2d(input_channels, 8, 3, 1, 1),
                             nn.ELU(), nn.MaxPool2d(2),
                             nn.Conv2d(8, 8, 3, 1, 1), nn.ELU(),
                             nn.MaxPool2d(2), nn.Conv2d(8, 16, 3, 1, 1),
                             nn.ELU(), nn.AdaptiveMaxPool2d((1, 1)),
                             AsMatrix(), nn.Linear(16, 10))
     return toy_net
Example #3
0
 def _make_test_model():
     toy_net = nn.Sequential(nn.Conv2d(3, 128, 3, 1, 1), nn.ELU(),
                             nn.MaxPool2d(2), nn.Conv2d(128, 128, 3, 1, 1),
                             nn.ELU(), nn.MaxPool2d(2),
                             nn.Conv2d(128, 256, 3, 1, 1), nn.ELU(),
                             nn.AdaptiveMaxPool2d((1, 1)), AsMatrix(),
                             nn.Linear(256, 10), nn.Softmax())
     return toy_net
Example #4
0
    def _make_test_model():
        import torch.nn as nn
        from inferno.extensions.layers.reshape import AsMatrix

        toy_net = nn.Sequential(nn.Conv2d(3, 128, 3, 1, 1), nn.ELU(),
                                nn.MaxPool2d(2), nn.Conv2d(128, 128, 3, 1, 1),
                                nn.ELU(), nn.MaxPool2d(2),
                                nn.Conv2d(128, 256, 3, 1, 1), nn.ELU(),
                                nn.AdaptiveAvgPool2d((1, 1)), AsMatrix(),
                                nn.Linear(256, 10), nn.Softmax())
        return toy_net