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


Python features.py方法代码示例

本文整理汇总了Python中features.py方法的典型用法代码示例。如果您正苦于以下问题:Python features.py方法的具体用法?Python features.py怎么用?Python features.py使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在features的用法示例。


在下文中一共展示了features.py方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_inference_input

# 需要导入模块: import features [as 别名]
# 或者: from features import py [as 别名]
def get_inference_input(params):
  """Set up placeholders for input features/labels.

  Args:
    params: An object to indicate the hyperparameters of the model.

  Returns:
    The features and output tensors that get passed into model_fn. Check
      dualnet_model.py for more details on the models input and output.
  """
  input_features = tf.placeholder(
      tf.float32, [None, params.board_size, params.board_size,
                   features.NEW_FEATURES_PLANES],
      name='pos_tensor')

  labels = {
      'pi_tensor': tf.placeholder(
          tf.float32, [None, params.board_size * params.board_size + 1]),
      'value_tensor': tf.placeholder(tf.float32, [None])
  }

  return input_features, labels 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:24,代码来源:dualnet.py

示例2: run

# 需要导入模块: import features [as 别名]
# 或者: from features import py [as 别名]
def run(self, position, use_random_symmetry=True):
    """Compute the policy and value output for a given position.

    Args:
      position: A given go board status
      use_random_symmetry: Apply random symmetry (defined in symmetries.py) to
        the extracted feature (defined in features.py) of the given position

    Returns:
      prob, value: The policy and value output (defined in dualnet_model.py)
    """
    probs, values = self.run_many(
        [position], use_random_symmetry=use_random_symmetry)
    return probs[0], values[0] 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:16,代码来源:dualnet.py

示例3: run_many

# 需要导入模块: import features [as 别名]
# 或者: from features import py [as 别名]
def run_many(self, positions, use_random_symmetry=True):
    """Compute the policy and value output for given positions.

    Args:
      positions: A list of positions for go board status
      use_random_symmetry: Apply random symmetry (defined in symmetries.py) to
        the extracted features (defined in features.py) of the given positions

    Returns:
      probabilities, value: The policy and value outputs (defined in
        dualnet_model.py)
    """
    def _extract_features(positions):
      return features.extract_features(self.hparams.board_size, positions)
    processed = list(map(_extract_features, positions))
    # processed = [
    #  features.extract_features(self.hparams.board_size, p) for p in positions]
    if use_random_symmetry:
      syms_used, processed = symmetries.randomize_symmetries_feat(processed)
    # feed_dict is a dict object to provide the input examples for the step of
    # inference. sess.run() returns the inference predictions (indicated by
    # self.inference_output) of the given input as outputs
    outputs = self.sess.run(
        self.inference_output, feed_dict={self.inference_input: processed})
    probabilities, value = outputs['policy_output'], outputs['value_output']
    if use_random_symmetry:
      probabilities = symmetries.invert_symmetries_pi(
          self.hparams.board_size, syms_used, probabilities)
    return probabilities, value 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:31,代码来源:dualnet.py


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