当前位置: 首页>>代码示例>>Python>>正文


Python preprocessing._one_hot方法代码示例

本文整理汇总了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) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:25,代码来源:test_preprocessing.py

示例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) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:27,代码来源:preprocessing_test.py

示例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) 
开发者ID:mlperf,项目名称:training,代码行数:26,代码来源:test_preprocessing.py


注:本文中的preprocessing._one_hot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。