def test_serialize_and_deserialize(self):
        spec = mobile_search_space_v3.mobilenet_v3_large()

        serialized = schema_io.serialize(spec)
        self.assertIsInstance(serialized, str)

        deserialized = schema_io.deserialize(serialized)
        self.assertIsInstance(deserialized, basic_specs.ConvTowerSpec)
        self.assertEqual(deserialized, spec)
示例#2
0
  def test_output_shapes(self):
    model_spec = mobile_search_space_v3.mobilenet_v3_large()
    model = mobile_model_v3.get_model(model_spec, num_classes=50)

    features = tf.ones([8, 224, 224, 3])
    model.build(features.shape)
    logits, endpoints = model.apply(features, training=True)

    self.assertEqual(logits.shape, tf.TensorShape([8, 50]))
    self.assertEqual([x.shape for x in endpoints], [
        [8, 112, 112, 16],
        [8, 56, 56, 24],
        [8, 28, 28, 40],
        [8, 14, 14, 112],
        [8, 7, 7, 160],
    ])
示例#3
0
  def test_output_shapes_with_variable_filter_sizes(self):
    filter_multipliers = (0.5, 1.0, 2.0)

    model_spec = mobile_search_space_v3.mobilenet_v3_large()
    model_spec = search_space_utils.scale_conv_tower_spec(
        model_spec, multipliers=filter_multipliers)
    model_spec = test_utils.with_random_masks(model_spec)
    model = mobile_model_v3.get_model(model_spec, num_classes=50)

    features = tf.ones([8, 224, 224, 3])
    model.build(features.shape)
    logits, endpoints = model.apply(features, training=True)

    self.assertEqual(logits.shape, tf.TensorShape([8, 50]))
    self.assertEqual([x.shape for x in endpoints], [
        [8, 112, 112, int(16 * max(filter_multipliers))],
        [8, 56, 56, int(24 * max(filter_multipliers))],
        [8, 28, 28, int(40 * max(filter_multipliers))],
        [8, 14, 14, int(112 * max(filter_multipliers))],
        [8, 7, 7, int(160 * max(filter_multipliers))],
    ])
 def test_mobilenet_v3_large(self):
     spec = mobile_search_space_v3.mobilenet_v3_large()
     self.assertIsInstance(spec, basic_specs.ConvTowerSpec)