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