本文整理汇总了Python中Features.make_feature_planes_stones_3liberties_4history_ko方法的典型用法代码示例。如果您正苦于以下问题:Python Features.make_feature_planes_stones_3liberties_4history_ko方法的具体用法?Python Features.make_feature_planes_stones_3liberties_4history_ko怎么用?Python Features.make_feature_planes_stones_3liberties_4history_ko使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Features
的用法示例。
在下文中一共展示了Features.make_feature_planes_stones_3liberties_4history_ko方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_influence_map
# 需要导入模块: import Features [as 别名]
# 或者: from Features import make_feature_planes_stones_3liberties_4history_ko [as 别名]
def make_influence_map(self):
if self.model.Nfeat == 15:
board_feature_planes = Features.make_feature_planes_stones_3liberties_4history_ko(self.board, self.board.color_to_play)
assert False, "for some reason I commented out the normalization???"
#Normalization.apply_featurewise_normalization_B(board_feature_planes)
else:
assert False
feature_batch = make_symmetry_batch(board_feature_planes)
feed_dict = {self.feature_planes: feature_batch}
logit_batch = self.sess.run(self.logits, feed_dict)
move_logits = Symmetry.average_plane_over_symmetries(logit_batch, self.model.N)
move_logits = move_logits.reshape((self.model.N, self.model.N))
influence_map = np.tanh(move_logits)
if self.board.color_to_play == Color.White:
influence_map *= -1
#influence_map = -1 * np.ones((self.model.N, self.model.N), dtype=np.float32)
return influence_map
示例2: pick_model_move
# 需要导入模块: import Features [as 别名]
# 或者: from Features import make_feature_planes_stones_3liberties_4history_ko [as 别名]
def pick_model_move(self, color):
if self.model.Nfeat == 15:
board_feature_planes = Features.make_feature_planes_stones_3liberties_4history_ko(self.board, color)
Normalization.apply_featurewise_normalization_B(board_feature_planes)
elif self.model.Nfeat == 21:
board_feature_planes = Features.make_feature_planes_stones_4liberties_4history_ko_4captures(self.board, color).astype(np.float32)
Normalization.apply_featurewise_normalization_C(board_feature_planes)
else:
assert False
feature_batch = Symmetry.make_symmetry_batch(board_feature_planes)
feed_dict = {self.feature_planes: feature_batch}
logit_batch = self.sess.run(self.logits, feed_dict)
move_logits = Symmetry.average_plane_over_symmetries(logit_batch, self.model.N)
softmax_temp = 1.0
move_probs = softmax(move_logits, softmax_temp)
# zero out illegal moves
for x in xrange(self.model.N):
for y in xrange(self.model.N):
ind = self.model.N * x + y
if not self.board.play_is_legal(x, y, color):
move_probs[ind] = 0
sum_probs = np.sum(move_probs)
if sum_probs == 0: return Move.Pass() # no legal moves, pass
move_probs /= sum_probs # re-normalize probabilities
pick_best = True
if pick_best:
move_ind = np.argmax(move_probs)
else:
move_ind = sample_from(move_probs)
move_x = move_ind / self.model.N
move_y = move_ind % self.model.N
self.last_move_probs = move_probs.reshape((self.board.N, self.board.N))
return Move(move_x, move_y)