Ejemplo n.º 1
0
def maxpool1d_conversion(config, name, verbose, maxpool_deeplift_mode,
                         **kwargs):
    pool1d_kwargs = prep_pool1d_kwargs(config=config,
                                       name=name,
                                       verbose=verbose)
    return [
        layers.MaxPool1D(maxpool_deeplift_mode=maxpool_deeplift_mode,
                         **pool1d_kwargs)
    ]
Ejemplo n.º 2
0
    def test_fprop_maxpool1d(self): 

        pool_layer = layers.MaxPool1D(pool_length=2,
                          stride=1,
                          padding=PaddingMode.valid,
                          maxpool_deeplift_mode=MaxPoolDeepLiftMode.gradient)
        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]
                                        ]]).transpose(0,2,1))
Ejemplo n.º 3
0
 def test_backprop_maxpool_gradients(self):
     pool_layer = layers.MaxPool1D(pool_length=2,
                   stride=1,
                   padding=PaddingMode.valid,
                   maxpool_deeplift_mode=MaxPoolDeepLiftMode.gradient)
     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]]).transpose(0,2,1))