當前位置: 首頁>>代碼示例>>Python>>正文


Python preprocessing.make_dataset_from_sgf方法代碼示例

本文整理匯總了Python中preprocessing.make_dataset_from_sgf方法的典型用法代碼示例。如果您正苦於以下問題:Python preprocessing.make_dataset_from_sgf方法的具體用法?Python preprocessing.make_dataset_from_sgf怎麽用?Python preprocessing.make_dataset_from_sgf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在preprocessing的用法示例。


在下文中一共展示了preprocessing.make_dataset_from_sgf方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_make_dataset_from_sgf

# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import make_dataset_from_sgf [as 別名]
def test_make_dataset_from_sgf(self):
        with tempfile.NamedTemporaryFile() as sgf_file, \
                tempfile.NamedTemporaryFile() as record_file:
            sgf_file.write(TEST_SGF.encode('utf8'))
            sgf_file.seek(0)
            preprocessing.make_dataset_from_sgf(
                sgf_file.name, record_file.name)
            recovered_data = self.extract_data(record_file.name)
        start_pos = go.Position()
        first_move = coords.from_sgf('fd')
        next_pos = start_pos.play_move(first_move)
        second_move = coords.from_sgf('cf')
        expected_data = [
            (
                features.extract_features(start_pos),
                preprocessing._one_hot(coords.to_flat(first_move)),
                -1
            ), (
                features.extract_features(next_pos),
                preprocessing._one_hot(coords.to_flat(second_move)),
                -1
            )]
        self.assertEqualData(expected_data, recovered_data) 
開發者ID:mlperf,項目名稱:training_results_v0.5,代碼行數:25,代碼來源:test_preprocessing.py

示例2: test_make_dataset_from_sgf

# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import make_dataset_from_sgf [as 別名]
def test_make_dataset_from_sgf(self):
    with tempfile.NamedTemporaryFile() as sgf_file, \
        tempfile.NamedTemporaryFile() as record_file:
      sgf_file.write(TEST_SGF.encode('utf8'))
      sgf_file.seek(0)
      preprocessing.make_dataset_from_sgf(
          utils_test.BOARD_SIZE, sgf_file.name, record_file.name)
      recovered_data = self.extract_data(record_file.name)
    start_pos = go.Position(utils_test.BOARD_SIZE)
    first_move = coords.from_sgf('fd')
    next_pos = start_pos.play_move(first_move)
    second_move = coords.from_sgf('cf')
    expected_data = [
        (
            features.extract_features(utils_test.BOARD_SIZE, start_pos),
            preprocessing._one_hot(utils_test.BOARD_SIZE, coords.to_flat(
                utils_test.BOARD_SIZE, first_move)), -1
        ),
        (
            features.extract_features(utils_test.BOARD_SIZE, next_pos),
            preprocessing._one_hot(utils_test.BOARD_SIZE, coords.to_flat(
                utils_test.BOARD_SIZE, second_move)), -1
        )
    ]
    self.assertEqualData(expected_data, recovered_data) 
開發者ID:itsamitgoel,項目名稱:Gun-Detector,代碼行數:27,代碼來源:preprocessing_test.py

示例3: test_make_dataset_from_sgf

# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import make_dataset_from_sgf [as 別名]
def test_make_dataset_from_sgf(self):
        with tempfile.NamedTemporaryFile() as sgf_file, \
                tempfile.NamedTemporaryFile() as record_file:
            sgf_file.write(TEST_SGF.encode('utf8'))
            sgf_file.seek(0)
            preprocessing.make_dataset_from_sgf(
                sgf_file.name, record_file.name)
            recovered_data = self.extract_data(record_file.name)
        start_pos = go.Position()
        first_move = coords.from_sgf('fd')
        next_pos = start_pos.play_move(first_move)
        second_move = coords.from_sgf('cf')
        f = dual_net.get_features()
        expected_data = [
            (
                features.extract_features(start_pos, f),
                preprocessing._one_hot(coords.to_flat(first_move)),
                -1
            ), (
                features.extract_features(next_pos, f),
                preprocessing._one_hot(coords.to_flat(second_move)),
                -1
            )]
        self.assertEqualData(expected_data, recovered_data) 
開發者ID:mlperf,項目名稱:training,代碼行數:26,代碼來源:test_preprocessing.py

示例4: test_train

# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import make_dataset_from_sgf [as 別名]
def test_train(self):
        with tempfile.TemporaryDirectory() as working_dir, \
                tempfile.NamedTemporaryFile() as tf_record:
            preprocessing.make_dataset_from_sgf(
                'tests/example_game.sgf', tf_record.name)
            dual_net.train(working_dir, [tf_record.name], 1, **fast_hparams) 
開發者ID:mlperf,項目名稱:training_results_v0.5,代碼行數:8,代碼來源:test_dual_net.py

示例5: test_train

# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import make_dataset_from_sgf [as 別名]
def test_train(self):
    with tempfile.TemporaryDirectory() as working_dir, \
        tempfile.NamedTemporaryFile() as tf_record:
      preprocessing.make_dataset_from_sgf(
          utils_test.BOARD_SIZE, 'example_game.sgf', tf_record.name)
      dualnet.train(
          working_dir, [tf_record.name], 1, model_params.DummyMiniGoParams()) 
開發者ID:itsamitgoel,項目名稱:Gun-Detector,代碼行數:9,代碼來源:dualnet_test.py

示例6: test_train

# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import make_dataset_from_sgf [as 別名]
def test_train(self):
        with tempfile.TemporaryDirectory() as working_dir, \
                tempfile.NamedTemporaryFile() as tf_record:
            flags.FLAGS.work_dir = working_dir
            preprocessing.make_dataset_from_sgf(
                'tests/example_game.sgf', tf_record.name)
            train.train([tf_record.name]) 
開發者ID:mlperf,項目名稱:training,代碼行數:9,代碼來源:test_dual_net.py


注:本文中的preprocessing.make_dataset_from_sgf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。