modified the network
This commit is contained in:
parent
5f923f565e
commit
493d361022
@ -4,13 +4,6 @@ import time
|
|||||||
import multi_gpu
|
import multi_gpu
|
||||||
import tensorflow.contrib.layers as layers
|
import tensorflow.contrib.layers as layers
|
||||||
|
|
||||||
data = np.load("data.npz")
|
|
||||||
boards = data["boards"]
|
|
||||||
wins = data["wins"]
|
|
||||||
ps = data["ps"]
|
|
||||||
print (boards.shape)
|
|
||||||
print (wins.shape)
|
|
||||||
print (ps.shape)
|
|
||||||
def residual_block(input, is_training):
|
def residual_block(input, is_training):
|
||||||
normalizer_params = {'is_training': is_training,
|
normalizer_params = {'is_training': is_training,
|
||||||
'updates_collections': None}
|
'updates_collections': None}
|
||||||
@ -44,7 +37,6 @@ def value_heads(input, is_training):
|
|||||||
h = layers.fully_connected(h, 1, activation_fn=tf.nn.tanh, weights_regularizer=layers.l2_regularizer(1e-4))
|
h = layers.fully_connected(h, 1, activation_fn=tf.nn.tanh, weights_regularizer=layers.l2_regularizer(1e-4))
|
||||||
return h
|
return h
|
||||||
|
|
||||||
|
|
||||||
x = tf.placeholder(tf.float32,shape=[None,19,19,17])
|
x = tf.placeholder(tf.float32,shape=[None,19,19,17])
|
||||||
is_training = tf.placeholder(tf.bool, shape=[])
|
is_training = tf.placeholder(tf.bool, shape=[])
|
||||||
z = tf.placeholder(tf.float32, shape=[None, 1])
|
z = tf.placeholder(tf.float32, shape=[None, 1])
|
||||||
@ -62,11 +54,19 @@ train_op = tf.train.RMSPropOptimizer(1e-2).minimize(total_loss)
|
|||||||
|
|
||||||
var_list = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
|
var_list = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
|
||||||
saver = tf.train.Saver(max_to_keep=10, var_list=var_list)
|
saver = tf.train.Saver(max_to_keep=10, var_list=var_list)
|
||||||
epochs = 100
|
def train():
|
||||||
batch_size = 32
|
data = np.load("data.npz")
|
||||||
batch_num = boards.shape[0] // batch_size
|
boards = data["boards"]
|
||||||
result_path = "./results/"
|
wins = data["wins"]
|
||||||
with multi_gpu.create_session() as sess:
|
ps = data["ps"]
|
||||||
|
print (boards.shape)
|
||||||
|
print (wins.shape)
|
||||||
|
print (ps.shape)
|
||||||
|
epochs = 100
|
||||||
|
batch_size = 32
|
||||||
|
batch_num = boards.shape[0] // batch_size
|
||||||
|
result_path = "./results/"
|
||||||
|
with multi_gpu.create_session() as sess:
|
||||||
sess.run(tf.global_variables_initializer())
|
sess.run(tf.global_variables_initializer())
|
||||||
ckpt_file = tf.train.latest_checkpoint(result_path)
|
ckpt_file = tf.train.latest_checkpoint(result_path)
|
||||||
if ckpt_file is not None:
|
if ckpt_file is not None:
|
||||||
@ -93,3 +93,15 @@ with multi_gpu.create_session() as sess:
|
|||||||
if iter % 20 == 0:
|
if iter % 20 == 0:
|
||||||
save_path = "Epoch{}.Iteration{}.ckpt".format(epoch, iter)
|
save_path = "Epoch{}.Iteration{}.ckpt".format(epoch, iter)
|
||||||
saver.save(sess, result_path + save_path)
|
saver.save(sess, result_path + save_path)
|
||||||
|
|
||||||
|
def forward(board):
|
||||||
|
result_path = "./results/"
|
||||||
|
with multi_gpu.create_session() as sess:
|
||||||
|
sess.run(tf.global_variables_initializer())
|
||||||
|
ckpt_file = tf.train.latest_checkpoint(result_path)
|
||||||
|
if ckpt_file is not None:
|
||||||
|
print('Restoring model from {}...'.format(ckpt_file))
|
||||||
|
saver.restore(sess, ckpt_file)
|
||||||
|
else:
|
||||||
|
raise ValueError("No model loaded")
|
||||||
|
return sess.run([p,v], feed_dict={x:board})
|
Loading…
x
Reference in New Issue
Block a user