def build(self, config): from zoo.automl.model.base_pytorch_model import PytorchBaseModel model = PytorchBaseModel(self.model_creator, self.optimizer_creator, self.loss_creator) model.build(config) return model
def build_from_ckpt(self, checkpoint_filename): '''Restore from a saved model''' from zoo.automl.model.base_pytorch_model import PytorchBaseModel model = PytorchBaseModel(self.model_creator, self.optimizer_creator, self.loss_creator) model.restore(checkpoint_filename) return model
def load(file_path): ''' Load the TSPipeline to a folder :param file_path: the folder location to load the pipeline ''' import pickle model_init_path = os.path.join(file_path, DEFAULT_MODEL_INIT_DIR) model_path = os.path.join(file_path, DEFAULT_BEST_MODEL_DIR) data_process_path = os.path.join(file_path, DEFAULT_DATA_PROCESS_DIR) best_config_path = os.path.join(file_path, DEFAULT_BEST_CONFIG_DIR) with open(model_init_path, "rb") as f: model_init = pickle.load(f) with open(data_process_path, "rb") as f: data_process = pickle.load(f) with open(best_config_path, "rb") as f: best_config = pickle.load(f) from zoo.automl.model.base_pytorch_model import PytorchBaseModel best_model = PytorchBaseModel(**model_init) best_model.restore(model_path) return TSPipeline(best_model, best_config, **data_process)
def build_from_ckpt(self, checkpoint_filename): '''Restore from a saved model''' if self.backend == "pytorch": from zoo.automl.model.base_pytorch_model import PytorchBaseModel model = PytorchBaseModel(**self.params) model.restore(checkpoint_filename) return model elif self.backend == "keras": from zoo.automl.model.base_keras_model import KerasBaseModel model = KerasBaseModel(**self.params) model.restore(checkpoint_filename) return model
def build(self, config): if self.backend == "pytorch": from zoo.automl.model.base_pytorch_model import PytorchBaseModel return PytorchBaseModel(**self.params, config=config) # elif self.backend == "keras": # from zoo.automl.model.base_keras_model import KerasBaseModel # return KerasBaseModel(**self.params, # config=config) elif self.cls is not None: return self.cls(config=config) else: builder = self.from_name(config["model"], dev_option=config["dev_option"]) return builder.cls(config=config)
def build(self, config): '''Build a new model''' if self.backend == "pytorch": from zoo.automl.model.base_pytorch_model import PytorchBaseModel model = PytorchBaseModel(**self.params) model.build(config) return model elif self.backend == "keras": from zoo.automl.model.base_keras_model import KerasBaseModel model = KerasBaseModel(**self.params) model.build(config) return model elif self.cls is not None: return self.cls(config=config) else: builder = self.from_name(config["model"], dev_option=config["dev_option"]) return builder.cls(config=config)