MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / __init__

Method __init__

rl2/a3c/worker.py:105–145  ·  view source on GitHub ↗
(
      self,
      name,
      env,
      policy_net,
      value_net,
      global_counter,
      returns_list,
      discount_factor=0.99,
      max_global_steps=None)

Source from the content-addressed store, hash-verified

103# returns_list (List) should be a global passed to every worker
104class Worker:
105 def __init__(
106 self,
107 name,
108 env,
109 policy_net,
110 value_net,
111 global_counter,
112 returns_list,
113 discount_factor=0.99,
114 max_global_steps=None):
115
116 self.name = name
117 self.env = env
118 self.global_policy_net = policy_net
119 self.global_value_net = value_net
120 self.global_counter = global_counter
121 self.discount_factor = discount_factor
122 self.max_global_steps = max_global_steps
123 self.global_step = tf.train.get_global_step()
124 self.img_transformer = ImageTransformer()
125
126 # Create local policy and value networks that belong only to this worker
127 with tf.variable_scope(name):
128 # self.policy_net = PolicyNetwork(num_outputs=policy_net.num_outputs)
129 # self.value_net = ValueNetwork()
130 self.policy_net, self.value_net = create_networks(policy_net.num_outputs)
131
132 # We will use this op to copy the global network weights
133 # back to the local policy and value networks
134 self.copy_params_op = get_copy_params_op(
135 tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope="global"),
136 tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope=self.name+'/'))
137
138 # These will take the gradients from the local networks
139 # and use those gradients to update the global network
140 self.vnet_train_op = make_train_op(self.value_net, self.global_value_net)
141 self.pnet_train_op = make_train_op(self.policy_net, self.global_policy_net)
142
143 self.state = None # Keep track of the current state
144 self.total_reward = 0. # After each episode print the total (sum of) reward
145 self.returns_list = returns_list # Global returns list to plot later
146
147 def run(self, sess, coord, t_max):
148 with sess.as_default(), sess.graph.as_default():

Callers

nothing calls this directly

Calls 4

create_networksFunction · 0.90
get_copy_params_opFunction · 0.85
make_train_opFunction · 0.85
ImageTransformerClass · 0.70

Tested by

no test coverage detected