1. How to use part of a model

    model = load_model(sys.argv[1], custom_objects = {'fmeasure': fmeasure})
    branch_model = model.get_layer(name = 'model_1')
    img_embed = Model(inputs = [branch_model.get_input_at(0)],
                      outputs = [branch_model.get_output_at(0)])

The ‘img_embed’ model is part of ‘branch_model’. We should realise that ‘Model()’ is a heavy cpu-cost function so it need to be create only once and then could be used many times.

2. How to save a model when using ‘multi_gpu_model’

orig_model = Model(x, y)
model = multi_gpu_model(orig_model, gpus = 2)
model.compile(optim, loss='binary_crossentropy', metrics = ['acc'])
....
model.fit_generator()
orig_model.save(PATH)

We should reserve original model. And only by using it, we can save the model to file.