def test_stop_layers1(self): from dlpy.applications import MobileNetV1 backbone = MobileNetV1(self.s, width=1248, height=1248) backbone_pure = backbone.to_functional_model( stop_layers=backbone.layers[-2]) # expect last layer to be a bn layer right before global average pooling self.assertEqual(backbone_pure.output_layers[0].name, 'conv_pw_13_bn')
def test_mobilenetv1(self): from dlpy.applications import MobileNetV1 model = MobileNetV1(self.s, n_classes=2, n_channels=3, depth_multiplier=10, alpha=2) self.assertTrue(len(model.layers) == 57) self.assertTrue(model.layers[49]._output_size == (7, 7, 2048)) model.print_summary() self.assertEqual(model.summary.iloc[7, -1], 36126720)
def test_multiple_stop_layers2(self): from dlpy.applications import MobileNetV1 resnet50 = MobileNetV1(self.s, "MobileNetV1") stop_layers = [resnet50.layers[x] for x in [-2, 4, -8] ] feature_extractor1 = resnet50.to_functional_model(stop_layers=stop_layers)