示例#1
0
    def validate_VGG16(cls):
        # Create a VGG16 Model without top layers
        model_base = VGG16(include_top=False, input_shape=CNN.input_shape())

        # Create top layers from own specifications
        model_top = CNN.get_top_layers(input_shape=model_base.output_shape[1:])
        model_top.load_weights(config.URL_TOP_MODEL)

        # Combine the 2 models into a full model
        model_full = Sequential()
        for layer in model_base.layers:
            model_full.add(layer)
        model_full.add(model_top)

        # Lock the pre-trained VGG16 layers
        for layer in model_full.layers[:25]:
            layer.trainable = False

        # Compile the full model
        model_full.compile(
            loss='categorical_crossentropy',
            optimizer=Adam(),
            metrics=['accuracy']
        )

        # Run the validation
        cls.run_validation(model_full)
示例#2
0
 def train_top_layers(cls):
     top_layers = CNN.get_top_layers(input_shape=CNN.input_shape())
     top_layers_compiled = CNN.compile_model(top_layers)
     cls.fit_model(top_layers_compiled, save_full=False)