Ejemplo n.º 1
0
 def build_model(self, local_session=True):
     if type(self.filename) == list:
         models = []
         for fn in self.filename:
             models.append(load_model(filename=fn))
         return MPIModel(models=models)
     else:
         return MPIModel(
             model=load_model(filename=self.filename,
                              custom_objects=self.custom_objects,
                              weights_file=self.weights))
Ejemplo n.º 2
0
 def build_model(self):
     if type(self.filename) == list:
         models = []
         for fn in self.filename:
             models.append(load_model(filename=fn))
         return MPIModel(models=models)
     else:
         return MPIModel(
             model=load_model(filename=self.filename,
                              json_str=self.json_str,
                              custom_objects=self.custom_objects,
                              weights_file=self.weights))
Ejemplo n.º 3
0
    def build_model_aux(self):
        import keras.backend as K

        with K.tf.device(self.device):
            if type(self.filename) == list:
                models = []
                self.weights = self.weights.split(
                    ',') if self.weights else [None] * len(self.filename)
                for fn, w in zip(self.filename, self.weights):
                    models.append(load_model(filename=fn, weights_file=w))
                return MPIModel(models=models)
            else:
                model = load_model(filename=self.filename,
                                   model=self.model,
                                   custom_objects=self.custom_objects,
                                   weights_file=self.weights)
                return MPIModel(model=model)
Ejemplo n.º 4
0
 def build_model(self):
     import keras.backend as K
     K.set_session( K.tf.Session( config=K.tf.ConfigProto(
         allow_soft_placement=True, log_device_placement=False,
         gpu_options=K.tf.GPUOptions(
             per_process_gpu_memory_fraction=1./self.comm.Get_size()) ) ) )
     with K.tf.device(self.device):
         model = load_model(filename=self.filename, json_str=self.json_str, 
                 custom_objects=self.custom_objects, weights_file=self.weights)
     return model
Ejemplo n.º 5
0
 def build_model(self):
     import keras.backend as K
     K.set_session(
         K.tf.Session(config=K.tf.ConfigProto(
             allow_soft_placement=True,
             log_device_placement=False,
             gpu_options=K.tf.GPUOptions(
                 per_process_gpu_memory_fraction=1. /
                 self.comm.Get_size()))))
     with K.tf.device(self.device):
         if type(self.filename) == list:
             models = []
             self.weights = self.weights.split(
                 ',') if self.weights else [None] * len(self.filename)
             for fn, w in zip(self.filename, self.weights):
                 models.append(load_model(filename=fn, weights_file=w))
             return MPIModel(models=models)
         else:
             model = load_model(filename=self.filename,
                                json_str=self.json_str,
                                custom_objects=self.custom_objects,
                                weights_file=self.weights)
             return MPIModel(model=model)
Ejemplo n.º 6
0
 def build_model(self):
     import keras.backend as K
     K.set_session(
         K.tf.Session(config=K.tf.ConfigProto(
             allow_soft_placement=True,
             log_device_placement=False,
             gpu_options=K.tf.GPUOptions(
                 per_process_gpu_memory_fraction=1. /
                 self.comm.Get_size()))))
     with K.tf.device(self.device):
         model = load_model(filename=self.filename,
                            json_str=self.json_str,
                            custom_objects=self.custom_objects,
                            weights_file=self.weights)
     return model
Ejemplo n.º 7
0
 def build_model(self):
     return load_model(filename=self.filename,
                       json_str=self.json_str,
                       custom_objects=self.custom_objects,
                       weights_file=self.weights)
Ejemplo n.º 8
0
 def build_model(self):
     return load_model(filename=self.filename, json_str=self.json_str, custom_objects=self.custom_objects, weights_file=self.weights)