(config)
return config
set default config
set default config
set default config
def setdefault_config(config):
  ''' set default config '''
  # This function only sets up those most commonly used parameters
  # which may not change frequently.

  config.setdefault('tfenv', dict())
  tfconf = config['tfenv']
  tfconf.setdefault('allow_soft_placement', True)
  tfconf.setdefault('log_device_placement', True)
  tfconf.setdefault('intra_op_parallelism_threads', 10)
  tfconf.setdefault('inter_op_parallelism_threads', 10)
  tfconf.setdefault('allow_growth', False)
  tfconf.setdefault('embedding_trainable', True)
  tfconf.setdefault('use_pretrained_embedding', False)

  model_conf = config['model']
  optimizer_conf = model_conf['optimizer']
  optimizer_conf.setdefault('dropout_keep_prob', 0.0)

  data_conf = config['data']
  saver_conf = data_conf['saver']
  saver_conf.setdefault('max_to_keep', 50)
  saver_conf.setdefault('checkpoint_every', 500)
  saver_conf.setdefault('evaluate_on_dev_every', 500)
  timestamp = str(int(time.time()))
  out_dir = os.path.abspath(os.path.join('/tmp', 'tf_runs', timestamp))
  saver_conf.setdefault('outdir', out_dir)
  saver_conf.setdefault('resume_model_path', out_dir)
  if not os.path.exists(out_dir):
    os.makedirs(out_dir)
  logging.info("Create temp output directory: {}\n".format(out_dir))

  data_conf.setdefault('outdir', out_dir)
  data_conf.setdefault('vocab', out_dir + '/vocab')
  data_conf.setdefault('label', out_dir + '/label')

  return config
def setdefault_config ( config ) : # This function only sets up those most commonly used parameters # which may not change frequently. config . setdefault ( 'tfenv' , dict ( ) ) tfconf = config [ 'tfenv' ] tfconf . setdefault ( 'allow_soft_placement' , True ) tfconf . setdefault ( 'log_device_placement' , True ) tfconf . setdefault ( 'intra_op_parallelism_threads' , 10 ) tfconf . setdefault ( 'inter_op_parallelism_threads' , 10 ) tfconf . setdefault ( 'allow_growth' , False ) tfconf . setdefault ( 'embedding_trainable' , True ) tfconf . setdefault ( 'use_pretrained_embedding' , False ) model_conf = config [ 'model' ] optimizer_conf = model_conf [ 'optimizer' ] optimizer_conf . setdefault ( 'dropout_keep_prob' , 0.0 ) data_conf = config [ 'data' ] saver_conf = data_conf [ 'saver' ] saver_conf . setdefault ( 'max_to_keep' , 50 ) saver_conf . setdefault ( 'checkpoint_every' , 500 ) saver_conf . setdefault ( 'evaluate_on_dev_every' , 500 ) timestamp = str ( int ( time . time ( ) ) ) out_dir = os . path . abspath ( os . path . join ( '/tmp' , 'tf_runs' , timestamp ) ) saver_conf . setdefault ( 'outdir' , out_dir ) saver_conf . setdefault ( 'resume_model_path' , out_dir ) if not os . path . exists ( out_dir ) : os . makedirs ( out_dir ) logging . info ( "Create temp output directory: {}\n" . format ( out_dir ) ) data_conf . setdefault ( 'outdir' , out_dir ) data_conf . setdefault ( 'vocab' , out_dir + '/vocab' ) data_conf . setdefault ( 'label' , out_dir + '/label' ) return config