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

Function learn

rl2/atari/dqn_tf.py:264–275  ·  view source on GitHub ↗
(model, target_model, experience_replay_buffer, gamma, batch_size)

Source from the content-addressed store, hash-verified

262
263
264def learn(model, target_model, experience_replay_buffer, gamma, batch_size):
265 # Sample experiences
266 states, actions, rewards, next_states, dones = experience_replay_buffer.get_minibatch()
267
268 # Calculate targets
269 next_Qs = target_model.predict(next_states)
270 next_Q = np.amax(next_Qs, axis=1)
271 targets = rewards + np.invert(dones).astype(np.float32) * gamma * next_Q
272
273 # Update model
274 loss = model.update(states, actions, targets)
275 return loss
276
277
278def play_one(

Callers 1

play_oneFunction · 0.70

Calls 3

get_minibatchMethod · 0.45
predictMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected