Exemplo n.º 1
0
 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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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)