Created
December 16, 2016 22:51
-
-
Save awjuliani/31d43d02816d801dc4e0e8440c56140a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copies one set of variables to another. | |
# Used to set worker network parameters to those of global network. | |
def update_target_graph(from_scope,to_scope): | |
from_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, from_scope) | |
to_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, to_scope) | |
op_holder = [] | |
for from_var,to_var in zip(from_vars,to_vars): | |
op_holder.append(to_var.assign(from_var)) | |
return op_holder | |
class Worker(): | |
def __init__(self,game,name,s_size,a_size,trainer,saver,model_path): | |
.... | |
.... | |
.... | |
#Create the local copy of the network and the tensorflow op to copy global paramters to local network | |
self.local_AC = AC_Network(s_size,a_size,self.name,trainer) | |
self.update_local_ops = update_target_graph('global',self.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment