本文整理匯總了Python中preprocessing._one_hot方法的典型用法代碼示例。如果您正苦於以下問題:Python preprocessing._one_hot方法的具體用法?Python preprocessing._one_hot怎麽用?Python preprocessing._one_hot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類preprocessing
的用法示例。
在下文中一共展示了preprocessing._one_hot方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_make_dataset_from_sgf
# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import _one_hot [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 _one_hot [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 _one_hot [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)