예제 #1
0
  def test_inference(self):
    with tempfile.TemporaryDirectory() as working_dir, \
        tempfile.TemporaryDirectory() as export_dir:
      dualnet.bootstrap(working_dir, model_params.DummyMiniGoParams())
      exported_model = os.path.join(export_dir, 'bootstrap-model')
      dualnet.export_model(working_dir, exported_model)

      n1 = dualnet.DualNetRunner(
          exported_model, model_params.DummyMiniGoParams())
      n1.run(go.Position(utils_test.BOARD_SIZE))

      n2 = dualnet.DualNetRunner(
          exported_model, model_params.DummyMiniGoParams())
      n2.run(go.Position(utils_test.BOARD_SIZE))
예제 #2
0
    def test_inference(self):
        with tempfile.TemporaryDirectory() as working_dir, \
            tempfile.TemporaryDirectory() as export_dir:
            dualnet.bootstrap(working_dir, model_params.DummyMiniGoParams())
            exported_model = os.path.join(export_dir, 'bootstrap-model')
            dualnet.export_model(working_dir, exported_model)

            n1 = dualnet.DualNetRunner(exported_model,
                                       model_params.DummyMiniGoParams())
            n1.run(go.Position(utils_test.BOARD_SIZE))

            n2 = dualnet.DualNetRunner(exported_model,
                                       model_params.DummyMiniGoParams())
            n2.run(go.Position(utils_test.BOARD_SIZE))
def bootstrap(estimator_model_dir, trained_models_dir, params):
  """Initialize the model with random weights.

  Args:
    estimator_model_dir: tf.estimator model directory.
    trained_models_dir: Dir to save the trained models. Here to export the first
      bootstrapped generation.
    params: A MiniGoParams instance of hyperparameters for the model.
  """
  bootstrap_name = utils.generate_model_name(0)
  _ensure_dir_exists(trained_models_dir)
  bootstrap_model_path = os.path.join(trained_models_dir, bootstrap_name)
  _ensure_dir_exists(estimator_model_dir)

  print('Bootstrapping with working dir {}\n Model 0 exported to {}'.format(
      estimator_model_dir, bootstrap_model_path))
  dualnet.bootstrap(estimator_model_dir, params)
  dualnet.export_model(estimator_model_dir, bootstrap_model_path)
예제 #4
0
파일: minigo.py 프로젝트: ALISCIFP/models
def bootstrap(estimator_model_dir, trained_models_dir, params):
  """Initialize the model with random weights.

  Args:
    estimator_model_dir: tf.estimator model directory.
    trained_models_dir: Dir to save the trained models. Here to export the first
      bootstrapped generation.
    params: A MiniGoParams instance of hyperparameters for the model.
  """
  bootstrap_name = utils.generate_model_name(0)
  _ensure_dir_exists(trained_models_dir)
  bootstrap_model_path = os.path.join(trained_models_dir, bootstrap_name)
  _ensure_dir_exists(estimator_model_dir)

  print('Bootstrapping with working dir {}\n Model 0 exported to {}'.format(
      estimator_model_dir, bootstrap_model_path))
  dualnet.bootstrap(estimator_model_dir, params)
  dualnet.export_model(estimator_model_dir, bootstrap_model_path)