bcf38b02cc7209d1baccd1302b5224f5faf2f00a,plugins/train/model/_base.py,_Inference,_make_inference_model,#_Inference#Any#,1454

Before Change


        logger.debug("Compiling model")
        layer_dict = {layer.name: layer for layer in saved_model.layers}
        compiled_layers = dict()
        for name, inbound in struct.items():
            if name not in required_layers:
                logger.debug("Skipping unused layer: "%s"", name)
                continue
            layer = layer_dict[name]
            logger.debug("Processing layer "%s": (layer: %s, inbound_nodes: %s)",
                         name, layer, inbound)
            if not inbound:
                logger.debug("Adding model inputs %s: %s", self._input_names, self._inputs)
                model = layer(self._inputs)
            else:
                layer_inputs = [compiled_layers[inp] for inp in inbound]
                logger.debug("Compiling layer "%s": layer inputs: %s", name, layer_inputs)
                model = layer(layer_inputs)
            compiled_layers[name] = model
        retval = KerasModel(self._inputs, model, name="{}_inference".format(saved_model.name))
        logger.debug("Compiled inference model "%s": %s", retval.name, retval)
        return retval

After Change


        struct = self._get_filtered_structure()
        model_inputs = self._get_inputs(saved_model.inputs)
        compiled_layers = dict()
        for layer in saved_model.layers:
            if layer.name not in struct:
                logger.debug("Skipping unused layer: "%s"", layer.name)
                continue
            inbound = struct[layer.name]
            logger.debug("Processing layer "%s": (layer: %s, inbound_nodes: %s)",
                         layer.name, layer, inbound)
            if not inbound:
                model = model_inputs
                logger.debug("Adding model inputs %s: %s", layer.name, model)
            else:
                layer_inputs = []
                for inp in inbound:
                    inbound_layer = compiled_layers[inp[0]]
                    if isinstance(inbound_layer, list) and len(inbound_layer) > 1:
                        // Multi output inputs
                        inbound_output_idx = inp[1]
                        logger.debug("Selecting output index %s from multi output inbound "
                                     "layer: %s", inbound_output_idx, inbound_layer)
                        layer_inputs.append(inbound_layer[inbound_output_idx])
                    else:
                        layer_inputs.append(inbound_layer)

                logger.debug("Compiling layer "%s": layer inputs: %s", layer.name, layer_inputs)
                model = layer(layer_inputs)
            compiled_layers[layer.name] = model
            retval = KerasModel(model_inputs, model, name="{}_inference".format(saved_model.name))
        logger.debug("Compiled inference model "%s": %s", retval.name, retval)
        return retval

    def _get_filtered_structure(self):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: deepfakes/faceswap
Commit Name: bcf38b02cc7209d1baccd1302b5224f5faf2f00a
Time: 2021-01-31
Author: 36920800+torzdf@users.noreply.github.com
File Name: plugins/train/model/_base.py
Class Name: _Inference
Method Name: _make_inference_model


Project Name: jhfjhfj1/autokeras
Commit Name: 16474aee0c575e615c78d32f2a170c3d7f8f0082
Time: 2017-12-30
Author: jhfjhfj1@gmail.com
File Name: autokeras/graph.py
Class Name: Graph
Method Name: produce_model


Project Name: explosion/thinc
Commit Name: 3140a57326e533548df00f0f128cd356932d400b
Time: 2017-01-11
Author: honnibal+gh@gmail.com
File Name: thinc/neural/_classes/model.py
Class Name: Model
Method Name: __init__