def serialize_config(params: config_definitions.ExperimentConfig, model_dir: str): """Serializes and saves the experiment config.""" params_save_path = os.path.join(model_dir, 'params.yaml') logging.info('Saving experiment configuration to %s', params_save_path) tf.io.gfile.makedirs(model_dir) hyperparams.save_params_dict_to_yaml(params, params_save_path)
def serialize_config(experiment_params: params.EdgeTPUBERTCustomParams, model_dir: str): """Serializes and saves the experiment config.""" params_save_path = os.path.join(model_dir, 'params.yaml') logging.info('Saving experiment configuration to %s', params_save_path) tf.io.gfile.makedirs(model_dir) hyperparams.save_params_dict_to_yaml(experiment_params, params_save_path)
def serialize_config(params: config_definitions.ExperimentConfig, model_dir: str): """Serializes and saves the experiment config.""" if model_dir is None: raise ValueError('model_dir must be specified, but got None') params_save_path = os.path.join(model_dir, 'params.yaml') logging.info('Saving experiment configuration to %s', params_save_path) tf.io.gfile.makedirs(model_dir) hyperparams.save_params_dict_to_yaml(params, params_save_path)
def test_encoder_from_yaml(self): config = encoders.EncoderConfig( type="bert", bert=encoders.BertEncoderConfig(num_layers=1)) encoder = encoders.build_encoder(config) ckpt = tf.train.Checkpoint(encoder=encoder) ckpt_path = ckpt.save(self.get_temp_dir() + "/ckpt") params_save_path = os.path.join(self.get_temp_dir(), "params.yaml") hyperparams.save_params_dict_to_yaml(config, params_save_path) retored_cfg = encoders.EncoderConfig.from_yaml(params_save_path) retored_encoder = encoders.build_encoder(retored_cfg) status = tf.train.Checkpoint(encoder=retored_encoder).restore(ckpt_path) status.assert_consumed()