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

Function learn

rl2/atari/dqn_theano.py:324–335  ·  view source on GitHub ↗
(model, target_model, experience_replay_buffer, gamma, batch_size)

Source from the content-addressed store, hash-verified

322
323
324def learn(model, target_model, experience_replay_buffer, gamma, batch_size):
325 # Sample experiences
326 states, actions, rewards, next_states, dones = experience_replay_buffer.get_minibatch()
327
328 # Calculate targets
329 next_Qs = target_model.predict(next_states)
330 next_Q = np.amax(next_Qs, axis=1)
331 targets = rewards + np.invert(dones).astype(np.float32) * gamma * next_Q
332
333 # Update model
334 loss = model.update(states, actions, targets)
335 return loss
336
337
338def 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