当前位置: 首页>>代码示例>>Python>>正文


Python learn_runner.run方法代码示例

本文整理汇总了Python中tensorflow.contrib.learn.python.learn.learn_runner.run方法的典型用法代码示例。如果您正苦于以下问题:Python learn_runner.run方法的具体用法?Python learn_runner.run怎么用?Python learn_runner.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.contrib.learn.python.learn.learn_runner的用法示例。


在下文中一共展示了learn_runner.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(argv=None):
  """Run a Tensorflow model on the Movielens dataset."""
  env = json.loads(os.environ.get('TF_CONFIG', '{}'))
  # First find out if there's a task value on the environment variable.
  # If there is none or it is empty define a default one.
  task_data = env.get('task') or {'type': 'master', 'index': 0}
  argv = sys.argv if argv is None else argv
  args = create_parser().parse_args(args=argv[1:])

  trial = task_data.get('trial')
  if trial is not None:
    output_path = os.path.join(args.output_path, trial)
  else:
    output_path = args.output_path

  learn_runner.run(experiment_fn=make_experiment_fn(args),
                   output_dir=output_path) 
开发者ID:GoogleCloudPlatform,项目名称:cloudml-samples,代码行数:19,代码来源:task.py

示例2: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(argv=None):
  """Run a Tensorflow model on the Reddit dataset."""
  env = json.loads(os.environ.get('TF_CONFIG', '{}'))
  # First find out if there's a task value on the environment variable.
  # If there is none or it is empty define a default one.
  task_data = env.get('task') or {'type': 'master', 'index': 0}
  argv = sys.argv if argv is None else argv
  args = create_parser().parse_args(args=argv[1:])

  trial = task_data.get('trial')
  if trial is not None:
    output_dir = os.path.join(args.output_path, trial)
  else:
    output_dir = args.output_path

  learn_runner.run(experiment_fn=get_experiment_fn(args),
                   output_dir=output_dir) 
开发者ID:GoogleCloudPlatform,项目名称:cloudml-samples,代码行数:19,代码来源:task.py

示例3: local_analysis

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def local_analysis(args):
  if args.analysis:
    # Already analyzed.
    return

  if not args.schema or not args.features:
    raise ValueError('Either --analysis, or both --schema and --features are provided.')

  tf_config = json.loads(os.environ.get('TF_CONFIG', '{}'))
  cluster_spec = tf_config.get('cluster', {})
  if len(cluster_spec.get('worker', [])) > 0:
    raise ValueError('If "schema" and "features" are provided, local analysis will run and ' +
                     'only BASIC scale-tier (no workers node) is supported.')

  if cluster_spec and not (args.schema.startswith('gs://') and args.features.startswith('gs://')):
    raise ValueError('Cloud trainer requires GCS paths for --schema and --features.')

  print('Running analysis.')
  schema = json.loads(file_io.read_file_to_string(args.schema).decode())
  features = json.loads(file_io.read_file_to_string(args.features).decode())
  args.analysis = os.path.join(args.job_dir, 'analysis')
  args.transform = True
  file_io.recursive_create_dir(args.analysis)
  feature_analysis.run_local_analysis(args.analysis, args.train, schema, features)
  print('Analysis done.') 
开发者ID:googledatalab,项目名称:pydatalab,代码行数:27,代码来源:task.py

示例4: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(unused_argv):
  if not FLAGS.input_dir:
    raise ValueError("Input dir should be specified.")

  if FLAGS.eval_dir:
    train_file_pattern = os.path.join(FLAGS.input_dir, "examples*")
    eval_file_pattern = os.path.join(FLAGS.eval_dir, "examples*")
  else:
    train_file_pattern = os.path.join(FLAGS.input_dir, "examples*[0-7]-of-*")
    eval_file_pattern = os.path.join(FLAGS.input_dir, "examples*[89]-of-*")

  if not FLAGS.num_classes:
    raise ValueError("Number of classes should be specified.")

  if not FLAGS.sparse_features:
    raise ValueError("Name of the sparse features should be specified.")

  learn_runner.run(
      experiment_fn=_def_experiment(
          train_file_pattern,
          eval_file_pattern,
          FLAGS.batch_size),
      output_dir=FLAGS.export_dir) 
开发者ID:googlegenomics,项目名称:cloudml-examples,代码行数:25,代码来源:variants_inference.py

示例5: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(argv=None):
  """Run a Tensorflow model on the Criteo dataset."""
  env = json.loads(os.environ.get('TF_CONFIG', '{}'))
  # First find out if there's a task value on the environment variable.
  # If there is none or it is empty define a default one.
  task_data = env.get('task') or {'type': 'master', 'index': 0}
  argv = sys.argv if argv is None else argv
  args = create_parser().parse_args(args=argv[1:])

  trial = task_data.get('trial')
  if trial is not None:
    output_dir = os.path.join(args.output_path, trial)
  else:
    output_dir = args.output_path

  # Do only evaluation if instructed so, or call Experiment's run.
  if args.eval_only_summary_filename:
    experiment = get_experiment_fn(args)(output_dir)
    # Note that evaluation here will appear as 'one_pass' in tensorboard.
    results = experiment.evaluate(delay_secs=0)
    # Converts numpy types to native types for json dumps.
    json_out = json.dumps(
        {key: value.tolist() for key, value in results.iteritems()})
    with tf.Session():
      tf.write_file(args.eval_only_summary_filename, json_out).run()
  else:
    learn_runner.run(experiment_fn=get_experiment_fn(args),
                     output_dir=output_dir) 
开发者ID:GoogleCloudPlatform,项目名称:cloudml-samples,代码行数:30,代码来源:task.py

示例6: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(unused_argv):
  tf.flags.mark_flag_as_required('model_dir')
  tf.flags.mark_flag_as_required('pipeline_config_path')
  config = tf.contrib.learn.RunConfig(model_dir=FLAGS.model_dir)
  learn_runner.run(
      experiment_fn=build_experiment_fn(FLAGS.num_train_steps,
                                        FLAGS.num_eval_steps),
      run_config=config,
      hparams=model_hparams.create_hparams()) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:11,代码来源:model.py

示例7: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(unused_argv):
  tf.flags.mark_flag_as_required('model_dir')
  tf.flags.mark_flag_as_required('pipeline_config_path')
  config = tf.contrib.learn.RunConfig(model_dir=FLAGS.model_dir)
  learn_runner.run(
      experiment_fn=_build_experiment_fn(FLAGS.num_train_steps,
                                         FLAGS.num_eval_steps),
      run_config=config,
      hparams=model_hparams.create_hparams()) 
开发者ID:ShreyAmbesh,项目名称:Traffic-Rule-Violation-Detection-System,代码行数:11,代码来源:model.py

示例8: run

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def run(params, problem_instance, train_preprocess_file_path,
        dev_preprocess_file_path):
  """Runs an Estimator locally or distributed.

  Args:
    data_dir: The directory the data can be found in.
    model_name: The name of the model to use.
    output_dir: The directory to store outputs in.
    train_steps: The number of steps to run training for.
    eval_steps: The number of steps to run evaluation for.
    schedule: (str) The schedule to run. The value here must
      be the name of one of Experiment's methods.
  """
  train_preprocess_file_path = os.path.abspath(train_preprocess_file_path)
  dev_preprocess_file_path = os.path.abspath(dev_preprocess_file_path)
  print("train preprocess", train_preprocess_file_path, "dev preprocess", dev_preprocess_file_path)
  exp_fn = make_experiment_fn(
      params,
      problem_instance,
      train_preprocess_file_path=train_preprocess_file_path,
      dev_preprocess_file_path=dev_preprocess_file_path)

  # Create hparams and run_config
  #run_config = trainer_utils.create_run_config(params.model_dir)
  run_config = create_run_config(params.model_dir)
  hparams = trainer_utils.create_hparams(
      params.hparams_set,
      params.data_dir,
      passed_hparams=params.hparams)

  if trainer_utils.is_chief():
    trainer_utils.save_metadata(params.model_dir, hparams)

  learn_runner.run(
      experiment_fn=exp_fn,
      schedule=params.schedule,
      run_config=run_config,
      hparams=hparams) 
开发者ID:steveash,项目名称:NETransliteration-COLING2018,代码行数:40,代码来源:g2p_trainer_utils.py

示例9: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(argv=None):
  """Run a Tensorflow model on the Iris dataset."""
  args = parse_arguments(sys.argv if argv is None else argv)

  tf.logging.set_verbosity(tf.logging.INFO)
  learn_runner.run(
      experiment_fn=get_experiment_fn(args),
      output_dir=args.job_dir) 
开发者ID:googledatalab,项目名称:pydatalab,代码行数:10,代码来源:task.py

示例10: __init__

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def __init__(self, epilog=None, datalab_epilog=None):
    self.full_parser = argparse.ArgumentParser(epilog=epilog)
    self.datalab_help = []
    self.datalab_epilog = datalab_epilog

    # Datalab help string
    self.full_parser.add_argument(
        '--datalab-help', action=self.make_datalab_help_action(),
        help='Show a smaller help message for DataLab only and exit')

    # The arguments added here are required to exist by Datalab's "%%ml train" magics.
    self.full_parser.add_argument(
        '--train', type=str, required=True, action='append', metavar='FILE')
    self.full_parser.add_argument(
        '--eval', type=str, required=True, action='append', metavar='FILE')
    self.full_parser.add_argument('--job-dir', type=str, required=True)
    self.full_parser.add_argument(
        '--analysis', type=str,
        metavar='ANALYSIS_OUTPUT_DIR',
        help=('Output folder of analysis. Should contain the schema, stats, and '
              'vocab files. Path must be on GCS if running cloud training. ' +
              'If absent, --schema and --features must be provided and ' +
              'the master trainer will do analysis locally.'))
    self.full_parser.add_argument(
        '--transform', action='store_true', default=False,
        help='If used, input data is raw csv that needs transformation. If analysis ' +
             'is required to run in trainerm this is automatically set to true.')
    self.full_parser.add_argument(
        '--schema', type=str,
        help='Schema of the training csv file. Only needed if analysis is required.')
    self.full_parser.add_argument(
        '--features', type=str,
        help='Feature transform config. Only needed if analysis is required.') 
开发者ID:googledatalab,项目名称:pydatalab,代码行数:35,代码来源:task.py

示例11: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(argv=None):
  args = parse_arguments(sys.argv if argv is None else argv)
  local_analysis(args)
  set_logging_level(args)
  # Supress TensorFlow Debugging info.
  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

  learn_runner.run(
      experiment_fn=get_experiment_fn(args),
      output_dir=args.job_dir) 
开发者ID:googledatalab,项目名称:pydatalab,代码行数:12,代码来源:task.py

示例12: main

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def main(unused_argv):
  print("Worker index: %d" % FLAGS.worker_index)
  learn_runner.run(experiment_fn=_create_experiment_fn,
                   output_dir=FLAGS.output_dir,
                   schedule=FLAGS.schedule) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:7,代码来源:census_widendeep.py

示例13: test_run_with_custom_schedule

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def test_run_with_custom_schedule(self):
    self.assertEqual(
        "simple_task, default=None.",
        learn_runner.run(build_experiment,
                         output_dir="/tmp",
                         schedule="simple_task")) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:8,代码来源:learn_runner_test.py

示例14: test_run_with_explicit_local_run

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def test_run_with_explicit_local_run(self):
    self.assertEqual(
        "local_run",
        learn_runner.run(build_experiment,
                         output_dir="/tmp",
                         schedule="local_run")) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:8,代码来源:learn_runner_test.py

示例15: test_schedule_from_tf_config

# 需要导入模块: from tensorflow.contrib.learn.python.learn import learn_runner [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.learn_runner import run [as 别名]
def test_schedule_from_tf_config(self):
    os.environ["TF_CONFIG"] = json.dumps(
        {"cluster": build_distributed_cluster_spec().as_dict(),
         "task": {"type": "worker"}})
    # RunConfig constructor will set job_name from TF_CONFIG.
    config = run_config.RunConfig()
    self.assertEqual(
        "train",
        learn_runner.run(lambda output_dir: TestExperiment(config=config),
                         output_dir="/tmp")) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:12,代码来源:learn_runner_test.py


注:本文中的tensorflow.contrib.learn.python.learn.learn_runner.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。