async def train(state, tf_records):
  """Run training and write a new model to the fsdb models_dir.

  Args:
    state: the RL loop State instance.
    tf_records: a list of paths to TensorFlow records to train on.
  """

  model_path = os.path.join(fsdb.models_dir(), state.train_model_name)
  await run(
      'python3', 'train.py', *tf_records,
      '--flagfile={}'.format(os.path.join(FLAGS.flags_dir, 'train.flags')),
      '--work_dir={}'.format(fsdb.working_dir()),
      '--export_path={}'.format(model_path),
      '--training_seed={}'.format(state.seed),
      '--freeze=true')
  # Append the time elapsed from when the RL was started to when this model
  # was trained.
  elapsed = time.time() - state.start_time
  timestamps_path = os.path.join(fsdb.models_dir(), 'train_times.txt')
  with gfile.Open(timestamps_path, 'a') as f:
    print('{:.3f} {}'.format(elapsed, state.train_model_name), file=f)
async def train ( state , tf_records ) : model_path = os . path . join ( fsdb . models_dir ( ) , state . train_model_name ) await run ( 'python3' , 'train.py' , * tf_records , '--flagfile={}' . format ( os . path . join ( FLAGS . flags_dir , 'train.flags' ) ) , '--work_dir={}' . format ( fsdb . working_dir ( ) ) , '--export_path={}' . format ( model_path ) , '--training_seed={}' . format ( state . seed ) , '--freeze=true' ) elapsed = time . time ( ) - state . start_time timestamps_path = os . path . join ( fsdb . models_dir ( ) , 'train_times.txt' ) with gfile . Open ( timestamps_path , 'a' ) as f : print ( '{:.3f} {}' . format ( elapsed , state . train_model_name ) , file = f )
Run training and write a new model to the fsdb models_dir.

  Args:
    state: the RL loop State instance.
    tf_records: a list of paths to TensorFlow records to train on.