O'Reilly logo

Python Reinforcement Learning Projects by Rajalingappaa Shanmugamani, Yang Wenzhuo, Sean Saito

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

network.py

This file contains our implementation of PolicyValueNetwork. In short, we construct a tf.estimator.Estimator that is trained using board states, policies, and self-play outcomes produced by MCTS self-play. The network has two heads: one acting as a value function, and the other acting as a policy network.

First, we define some layers that will be used by PolicyValueNetwork:

import functoolsimport loggingimport os.pathimport tensorflow as tfimport featuresimport preprocessingimport utilsfrom config import GLOBAL_PARAMETER_STORE, GOPARAMETERSfrom constants import *logger = logging.getLogger(__name__)logger.setLevel(logging.INFO)def create_partial_bn_layer(params):    return functools.partial(tf.layers.batch_normalization,        momentum

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required