Beispiel #1
0
def maxpool1d_conversion(layer, name, verbose, maxpool_deeplift_mode,
                         **kwargs):
    pool1d_kwargs = prep_pool1d_kwargs(layer=layer, name=name, verbose=verbose)
    return [
        blobs.MaxPool1D(maxpool_deeplift_mode=maxpool_deeplift_mode,
                        **pool1d_kwargs)
    ]
Beispiel #2
0
    def test_fprop_maxpool1d(self): 

        pool_layer = blobs.MaxPool1D(pool_length=2,
                          stride=1,
                          border_mode=PaddingMode.valid,
                          ignore_border=True,
                          maxpool_deeplift_mode=MaxPoolDeepLiftMode.gradient,
                          channels_come_last=False)
        self.create_small_net_with_pool_layer(pool_layer,
                                              outputs_per_channel=3)

        func = compile_func([self.input_layer.get_activation_vars()],
                            self.pool_layer.get_activation_vars())
        np.testing.assert_almost_equal(func(self.backprop_test_inps),
                                       np.array(
                                        [[
                                         [1,4,4],
                                         [3,2,1]],
                                        [[ 0,-1,-2],
                                         [-2,-1, 0]
                                        ]]))
Beispiel #3
0
 def test_backprop_maxpool_gradients(self):
     pool_layer = blobs.MaxPool1D(pool_length=2,
                   stride=1,
                   border_mode=PaddingMode.valid,
                   ignore_border=True,
                   maxpool_deeplift_mode=MaxPoolDeepLiftMode.gradient,
                   channels_come_last=False)
     self.create_small_net_with_pool_layer(pool_layer,
                                           outputs_per_channel=3)
     self.dense_layer.update_task_index(task_index=0)
     func = compile_func([
                 self.input_layer.get_activation_vars(),
                 self.input_layer.get_reference_vars()],
             self.input_layer.get_mxts())
     np.testing.assert_almost_equal(
         func(self.backprop_test_inps,
              np.ones_like(self.backprop_test_inps)*self.reference_inps),
               np.array([
               [np.array([0, 1, 2, 0])*2,
                np.array([1, 1, 1, 0])*3],
               [np.array([1, 1, 1, 0])*2,
                np.array([0, 1, 1, 1])*3]]))