Пример #1
0
 def testDivisibleBy(self):
     tf.reset_default_graph()
     mobilenet_v2.mobilenet(tf.placeholder(tf.float32, (10, 224, 224, 16)),
                            conv_defs=mobilenet_v2.V2_DEF,
                            divisible_by=16,
                            min_depth=32)
     s = [
         op.outputs[0].get_shape().as_list()[-1]
         for op in find_ops('Conv2D')
     ]
     s = set(s)
     self.assertSameElements(
         [32, 64, 96, 160, 192, 320, 384, 576, 960, 1280, 1001], s)
Пример #2
0
 def testDivisibleByWithArgScope(self):
     tf.reset_default_graph()
     # Verifies that depth_multiplier arg scope actually works
     # if no default min_depth is provided.
     with slim.arg_scope((mobilenet.depth_multiplier, ), min_depth=32):
         mobilenet_v2.mobilenet(tf.placeholder(tf.float32,
                                               (10, 224, 224, 2)),
                                conv_defs=mobilenet_v2.V2_DEF,
                                depth_multiplier=0.1)
         s = [
             op.outputs[0].get_shape().as_list()[-1]
             for op in find_ops('Conv2D')
         ]
         s = set(s)
         self.assertSameElements(s, [32, 192, 128, 1001])
Пример #3
0
    def testFineGrained(self):
        tf.reset_default_graph()
        # Verifies that depth_multiplier arg scope actually works
        # if no default min_depth is provided.

        mobilenet_v2.mobilenet(tf.placeholder(tf.float32, (10, 224, 224, 2)),
                               conv_defs=mobilenet_v2.V2_DEF,
                               depth_multiplier=0.01,
                               finegrain_classification_mode=True)
        s = [
            op.outputs[0].get_shape().as_list()[-1]
            for op in find_ops('Conv2D')
        ]
        s = set(s)
        # All convolutions will be 8->48, except for the last one.
        self.assertSameElements(s, [8, 48, 1001, 1280])
Пример #4
0
    def testImageSizes(self):
        for input_size, output_size in [(224, 7), (192, 6), (160, 5), (128, 4),
                                        (96, 3)]:
            tf.reset_default_graph()
            _, ep = mobilenet_v2.mobilenet(
                tf.placeholder(tf.float32, (10, input_size, input_size, 3)))

            self.assertEqual(ep['layer_18/output'].get_shape().as_list()[1:3],
                             [output_size] * 2)