Python gin.operative_config_str() Examples

The following are 5 code examples of gin.operative_config_str(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gin , or try the search function .
Example #1
Source File: trax.py    From BERT with Apache License 2.0 5 votes vote down vote up
def _save_gin(output_dir, sw=None):
  config_path = os.path.join(output_dir, "config.gin")
  config_str = gin.operative_config_str()
  with gfile.GFile(config_path, "w") as f:
    f.write(config_str)
  if sw:
    sw.text("gin_config",
            jaxboard.markdownify_operative_config_str(config_str)) 
Example #2
Source File: training.py    From trax with Apache License 2.0 5 votes vote down vote up
def save_gin(self):
    assert self._output_dir is not None
    config_path = os.path.join(self._output_dir, 'config.gin')
    config_str = gin.operative_config_str()
    with tf.io.gfile.GFile(config_path, 'w') as f:
      f.write(config_str)
    if self._sw:
      self._sw.text('gin_config',
                    jaxboard.markdownify_operative_config_str(config_str)) 
Example #3
Source File: trainer_lib.py    From trax with Apache License 2.0 5 votes vote down vote up
def save_gin(self):
    """"Saves the operative gin config, only if it is the chief."""
    if not self._is_chief:
      return
    assert self._output_dir is not None
    config_path = os.path.join(self._output_dir, 'config.gin')
    config_str = gin.operative_config_str()
    with tf.io.gfile.GFile(config_path, 'w') as f:
      f.write(config_str)
    sw = self._train_sw
    if sw:
      sw.text('gin_config',
              jaxboard.markdownify_operative_config_str(config_str)) 
Example #4
Source File: experiment.py    From reaver with MIT License 5 votes vote down vote up
def save_gin_config(self):
        with open(self.config_path, 'w') as cfg_file:
            cfg_file.write(gin.operative_config_str()) 
Example #5
Source File: train.py    From meta-dataset with Apache License 2.0 5 votes vote down vote up
def record_operative_gin_configurations(operative_config_dir):
  """Record operative Gin configurations in the given directory."""
  gin_log_file = operative_config_path(operative_config_dir)
  # If it exists already, rename it instead of overwriting it.
  # This just saves the previous one, not all the ones before.
  if tf.io.gfile.exists(gin_log_file):
    tf.io.gfile.rename(gin_log_file, gin_log_file + '.old', overwrite=True)
  with tf.io.gfile.GFile(gin_log_file, 'w') as f:
    f.write(gin.operative_config_str())