Exemplo n.º 1
0
    def testTupleWithEmptyTupleAttr(self):
        attrs = {"something2": "()"}

        attr_dict = AttrDictionary(attrs)
        a, b = attr_dict.tuple("something", int, (2, 3))
        self.assertEqual(2, a)
        self.assertEqual(3, b)
Exemplo n.º 2
0
    def testIntWithoutAttr(self):
        attrs = {
            "something2": "5"
        }

        attr_dict = AttrDictionary(attrs)
        attr = attr_dict.float("something", 1)
        self.assertEqual(1, attr)
Exemplo n.º 3
0
    def testFloatAttr(self):
        attrs = {
            "something": "0.5"
        }

        attr_dict = AttrDictionary(attrs)
        attr = attr_dict.float("something", 0.1)
        self.assertEqual(0.5, attr)
Exemplo n.º 4
0
    def testStrAttrWithoutAttr(self):
        attrs = {
            "something2": "Val"
        }

        attr_dict = AttrDictionary(attrs)
        attr = attr_dict.str("something", "Text")
        self.assertEqual("Text", attr)
Exemplo n.º 5
0
    def testBoolWithoutAttr(self):
        attrs = {
            "something": "1"
        }

        attr_dict = AttrDictionary(attrs)
        global_pool = attr_dict.bool("global_pool", False)
        self.assertEqual(False, global_pool)
Exemplo n.º 6
0
    def testBoolAsDigits(self):
        attrs = {
            "global_pool": "1"
        }

        attr_dict = AttrDictionary(attrs)
        global_pool = attr_dict.bool("global_pool", False)
        self.assertEqual(True, global_pool)
Exemplo n.º 7
0
    def testIntWithAttrNone(self):
        attrs = {
            "something": "None"
        }

        attr_dict = AttrDictionary(attrs)
        attr = attr_dict.int("something", None)
        self.assertEqual(None, attr)
Exemplo n.º 8
0
    def testTupleWithoutAttr(self):
        attrs = {"something2": "(5,6,7)"}

        attr_dict = AttrDictionary(attrs)
        a, b, c = attr_dict.tuple("something", int, (1, 2, 3))
        self.assertEqual(1, a)
        self.assertEqual(2, b)
        self.assertEqual(3, c)
Exemplo n.º 9
0
    def testTupleAttr(self):
        attrs = {"something": "(5,6,7)"}

        attr_dict = AttrDictionary(attrs)
        a, b, c = attr_dict.tuple("something", int, (1, 2, 3))
        self.assertEqual(5, a)
        self.assertEqual(6, b)
        self.assertEqual(7, c)
Exemplo n.º 10
0
    def testListWithoutAttr(self):
        attrs = {"something2": "5,6,7"}

        attr_dict = AttrDictionary(attrs)
        l = attr_dict.list("something", int, [1, 2, 3])
        self.assertEqual(1, l[0])
        self.assertEqual(2, l[1])
        self.assertEqual(3, l[2])
Exemplo n.º 11
0
    def testListAttr(self):
        attrs = {"something": "5,6,7"}

        attr_dict = AttrDictionary(attrs)
        l = attr_dict.list("something", int, [1, 2, 3])
        self.assertEqual(5, l[0])
        self.assertEqual(6, l[1])
        self.assertEqual(7, l[2])
Exemplo n.º 12
0
    def test_extract_slice_axis_layer(self):
        graph = build_graph(
            {'node_1': {'type': 'Identity', 'value': None, 'kind': 'op', 'op': 'Parameter'},
             'slice_axis_node': {'type': 'sigmoid', 'kind': 'op', 'op': 'slice_axis', },
             'node_3': {'type': 'Identity', 'value': None, 'kind': 'op'},
             },
            [
                ('node_1', 'slice_axis_node'),
                ('slice_axis_node', 'node_3'),
            ],
            {
                'slice_axis_node': {'symbol_dict': {'attrs': {'axis': 0, 'begin': 10, 'end': 25}}},
            })

        exp_attrs = {
            'op': 'Crop',
            'axis': 0,
            'offset': 10,
            'dim': 25
        }

        slice_axis_node = Node(graph, 'slice_axis_node')
        res = slice_axis_ext(AttrDictionary(slice_axis_node['symbol_dict']['attrs']))

        for key in exp_attrs.keys():
            self.assertEqual(res[key], exp_attrs[key])
Exemplo n.º 13
0
    def test_multi_box_prior_check_attrs(self):
        attrs = {
            'ratios': '(1,2,0.5)',
            'steps': '(0.02666666666666667, 0.02666666666666667)',
            'clip': 'False',
            'sizes': '(0.1,0.141)'
        }

        res = multi_box_prior_ext(AttrDictionary(attrs))
        exp_attrs = {
            'type': 'PriorBox',
            'step': 0.02666666666666667,
            'offset': 0.5,
            'variance': '0.100000,0.100000,0.200000,0.200000',
            'flip': 0,
            'clip': 0,
            'min_size': [0.1, 0.141],
            'max_size': '',
            'aspect_ratio': [1, 2, 0.5],
        }

        for key in exp_attrs.keys():
            if key in ['aspect_ratio', 'variance']:
                np.testing.assert_equal(res[key], exp_attrs[key])
            else:
                self.assertEqual(res[key], exp_attrs[key])