def _collectModels(self, kerasModelBytesRDD):
     """
     Collect Keras models on workers to MLlib Models on the driver.
     :param kerasModelBytesRDD: RDD of (param_map, model_bytes) tuples
     :return: generator of (index, MLlib model) tuples
     """
     for (i, param_map, model_bytes) in kerasModelBytesRDD.collect():
         model_filename = kmutil.bytes_to_h5file(model_bytes)
         yield i, self._copyValues(KerasImageFileTransformer(modelFile=model_filename),
                                   extra=param_map)
 def _collectModels(self, kerasModelBytesRDD):
     """
     Collect Keras models on workers to MLlib Models on the driver.
     :param kerasModelBytesRDD: RDD of (param_map, model_bytes) tuples
     :return: generator of (index, MLlib model) tuples
     """
     for (i, param_map, model_bytes) in kerasModelBytesRDD.collect():
         model_filename = kmutil.bytes_to_h5file(model_bytes)
         yield i, self._copyValues(KerasImageFileTransformer(modelFile=model_filename),
                                   extra=param_map)
    def _collectModels(self, kerasModelsBytesRDD):
        """
        Collect Keras models on workers to MLlib Models on the driver.
        :param kerasModelBytesRDD: RDD of (param_map, model_bytes) tuples
        :param paramMaps: list of ParamMaps matching the maps in `kerasModelsRDD`
        :return: list of MLlib models
        """
        transformers = []
        for (param_map, model_bytes) in kerasModelsBytesRDD.collect():
            model_filename = kmutil.bytes_to_h5file(model_bytes)
            transformers.append({
                'paramMap':
                param_map,
                'transformer':
                KerasImageFileTransformer(modelFile=model_filename)
            })

        return transformers