예제 #1
0
파일: model.py 프로젝트: vloncar/mpi_learn
 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))
예제 #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))
예제 #3
0
파일: model.py 프로젝트: vloncar/mpi_learn
    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)
예제 #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
예제 #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)
예제 #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
예제 #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)
예제 #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)