本文整理匯總了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)
示例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)
示例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)
示例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)
示例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())
示例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])