def persist(self, path):
    if self.model:
        arch_file = os.path.join(path, 'keras_arch.json')
        weights_file = os.path.join(path, 'keras_weights.h5')
        config_file = os.path.join(path, 'keras_policy.json')
        utils.create_dir_for_file(weights_file)
        utils.dump_obj_as_str_to_file(arch_file, self.model.to_json())
        self._persist_configuration(config_file)
        self.model.save_weights(weights_file, overwrite=True)
    else:
        warnings.warn('Persist called without a trained model present. Nothing to persist then!')
def persist(self, path):
    if self.model:
        arch_file = os.path.join(path, 'keras_arch.json')
        weights_file = os.path.join(path, 'keras_weights.h5')
        config_file = os.path.join(path, 'keras_policy.json')
        utils.create_dir_for_file(weights_file)
        utils.dump_obj_as_str_to_file(arch_file, self.model.to_json())
        self._persist_configuration(config_file)
        self.model.save_weights(weights_file, overwrite=True)
    else:
        warnings.warn('Persist called without a trained model present. Nothing to persist then!')