Merge branch 'master' of gitfub.space:Pownie/backgammon

This commit is contained in:
Alexander Munch-Hansen 2018-03-06 12:57:38 +01:00
commit 7c9127b746

View File

@ -18,6 +18,11 @@ class Network:
# TODO: Actually compile tensorflow properly # TODO: Actually compile tensorflow properly
#os.environ["TF_CPP_MIN_LOG_LEVEL"]="2" #os.environ["TF_CPP_MIN_LOG_LEVEL"]="2"
def custom_tanh(self, x, name=None):
a = tf.Variable(2.00, tf.float32)
return tf.scalar_mul(a, tf.tanh(x, name))
def __init__(self, session): def __init__(self, session):
self.session = session self.session = session
@ -40,12 +45,10 @@ class Network:
b_1 = tf.zeros(hidden_size,) b_1 = tf.zeros(hidden_size,)
b_2 = tf.zeros(output_size,) b_2 = tf.zeros(output_size,)
value_after_input = tf.sigmoid(tf.matmul(self.x, W_1) + b_1, name='hidden_layer') value_after_input = self.custom_tanh(tf.matmul(self.x, W_1) + b_1, name='hidden_layer')
# TODO: Remember to make this tanh * 2 # TODO: Remember to make this tanh * 2
# self.value = tf.layers.dense(input=value_after_input, units=hidden_size, \ self.value = self.custom_tanh(tf.matmul(value_after_input, W_2) + b_2, name='output_layer')
# activation=self.custom_tanh, kernel_initializer=xavier_init())
self.value = 2*tf.nn.tanh(tf.matmul(value_after_input, W_2) + b_2, name='output_layer')
# tf.reduce_sum basically finds the sum of it's input, so this gives the difference between the two values, in case they should be lists, which they might be if our input changes # tf.reduce_sum basically finds the sum of it's input, so this gives the difference between the two values, in case they should be lists, which they might be if our input changes
difference_in_values = tf.reduce_sum(self.value_next - self.value, name='difference') difference_in_values = tf.reduce_sum(self.value_next - self.value, name='difference')
@ -67,7 +70,6 @@ class Network:
self.saver = tf.train.Saver(max_to_keep=1) self.saver = tf.train.Saver(max_to_keep=1)
self.session.run(tf.global_variables_initializer()) self.session.run(tf.global_variables_initializer())
def eval_state(self, state): def eval_state(self, state):
# Run state through a network # Run state through a network