本文整理汇总了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])