示例#1
0
    def test_conv_zb_active_bias(self):
        expected_result = [[[[0, 0], [0, 0],
                             [-4.232906357e-05, -4.264118594e-05]],
                            [[0, 0], [0, 0],
                             [-0.0002441027169, -0.0001287812181]],
                            [[0.0511805643, 0.03121454034],
                             [0.1487963475, 0.1636981056],
                             [-0.001490325286, -0.0005114089294]]]]

        config = LRPConfiguration()
        config.set(
            LAYER.LINEAR,
            EpsilonConfiguration(epsilon=1,
                                 bias_strategy=BIAS_STRATEGY.IGNORE))
        config.set_first_layer_zb(_c(-0.5),
                                  _c(2.),
                                  bias_strategy=BIAS_STRATEGY.ACTIVE)

        self._do_convolutional_test(config, expected_result)
示例#2
0
    def test_conv_zb_all_bias(self):
        expected_result = [[[[0, 0], [0, 0],
                             [-3.049265839e-05, -3.080478076e-05]],
                            [[0, 0], [0, 0],
                             [-0.0002322663118, -0.0001169448129]],
                            [[0.04284719936, 0.0228811754],
                             [0.1404629826, 0.1553647406],
                             [-0.001139536047, -0.0001606196899]]]]

        config = LRPConfiguration()
        config.set(
            LAYER.LINEAR,
            EpsilonConfiguration(epsilon=1,
                                 bias_strategy=BIAS_STRATEGY.IGNORE))
        config.set_first_layer_zb(_c(-0.5),
                                  _c(2.),
                                  bias_strategy=BIAS_STRATEGY.ALL)

        self._do_convolutional_test(config, expected_result)
示例#3
0
    def test_conv_zb_no_bias(self):
        expected_result = [[[[0, 0], [0, 0],
                             [-1.865625321e-05, -1.896837558e-05]],
                            [[0, 0], [0, 0],
                             [-0.0002204299066, -0.0001051084077]],
                            [[0.03451383443, 0.01454781046],
                             [0.1321296177, 0.1470313757],
                             [-0.0010226063, -4.368994345e-05]]]]

        config = LRPConfiguration()
        config.set(
            LAYER.LINEAR,
            EpsilonConfiguration(epsilon=1,
                                 bias_strategy=BIAS_STRATEGY.IGNORE))
        config.set_first_layer_zb(_c(-0.5),
                                  _c(2.),
                                  bias_strategy=BIAS_STRATEGY.NONE)

        self._do_convolutional_test(config, expected_result)
示例#4
0
    def test_conv_zb_ignore_bias(self):
        expected_result = [[[[0, 0], [0, 0],
                             [-2.352069164e-05, -2.391419691e-05]],
                            [[0, 0], [0, 0],
                             [-0.0002779048828, -0.0001325144132]],
                            [[0.04152410963, 0.01750268803],
                             [0.1589671162, 0.1768956439],
                             [-0.001919716057, -8.201815885e-05]]]]

        config = LRPConfiguration()
        config.set(
            LAYER.LINEAR,
            EpsilonConfiguration(epsilon=1,
                                 bias_strategy=BIAS_STRATEGY.IGNORE))
        config.set_first_layer_zb(_c(-0.5),
                                  _c(2.),
                                  bias_strategy=BIAS_STRATEGY.IGNORE)

        self._do_convolutional_test(config, expected_result)
示例#5
0
    def test_zb_all_bias(self):
        config = LRPConfiguration()
        config.set(LAYER.LINEAR,
                   AlphaBetaConfiguration(bias_strategy=BIAS_STRATEGY.IGNORE))
        config.set_first_layer_zb(_l(-1), _l(1), BIAS_STRATEGY.ALL)

        expected_result = [[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],
                           [[
                               0.0698808139, -0.0423098508, 0.449498635,
                               0.008238149531, 0.3091131246
                           ],
                            [
                                0.0628218352, 0.1973151543, 0.1616683269,
                                0.09610076993, 0.07305203625
                            ]],
                           [[0, 0, 0, 0, 0],
                            [
                                0.193439198, 0.01149534468, 0.02828658801,
                                0.2718921108, 0.04192110389
                            ]]]

        self._do_linear_test(config, np.array(expected_result))
示例#6
0
    def test_zb_no_bias(self):
        config = LRPConfiguration()
        config.set(LAYER.LINEAR,
                   AlphaBetaConfiguration(bias_strategy=BIAS_STRATEGY.IGNORE))
        config.set_first_layer_zb(_l(-1), _l(1), BIAS_STRATEGY.NONE)

        expected_result = [[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],
                           [[
                               0.1145575292, 0.002366864524, 0.4941753504,
                               0.05291486486, 0.3537898399
                           ],
                            [
                                0.07031890972, 0.2048122289, 0.1691654014,
                                0.1035978445, 0.08054911078
                            ]],
                           [[0, 0, 0, 0, 0],
                            [
                                0.2102658664, 0.0283220131, 0.04511325643,
                                0.2887187793, 0.05874777231
                            ]]]

        self._do_linear_test(config, np.array(expected_result))
示例#7
0
    def test_zb_ignore_bias(self):
        config = LRPConfiguration()
        config.set(LAYER.LINEAR,
                   AlphaBetaConfiguration(bias_strategy=BIAS_STRATEGY.IGNORE))
        config.set_first_layer_zb(_l(-1), _l(1), BIAS_STRATEGY.IGNORE)

        expected_result = [[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],
                           [[
                               0.08941490911, 0.001847394735, 0.3857157564,
                               0.04130132575, 0.2761414863
                           ],
                            [
                                0.06524084895, 0.2049935833, 0.1593686046,
                                0.08435578325, 0.07699930241
                            ]],
                           [[0, 0, 0, 0, 0],
                            [
                                0.1842489119, 0.02888073415, 0.04590480826,
                                0.2341442052, 0.05385568583
                            ]]]

        self._do_linear_test(config, np.array(expected_result))