Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@awjuliani
Created December 16, 2016 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awjuliani/31d43d02816d801dc4e0e8440c56140a to your computer and use it in GitHub Desktop.
Save awjuliani/31d43d02816d801dc4e0e8440c56140a to your computer and use it in GitHub Desktop.
# 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