MCPcopy Index your code
hub / github.com/pytorch/tutorials / plot_durations

Function plot_durations

intermediate_source/reinforcement_q_learning.py:320–343  ·  view source on GitHub ↗
(show_result=False)

Source from the content-addressed store, hash-verified

318
319
320def plot_durations(show_result=False):
321 plt.figure(1)
322 durations_t = torch.tensor(episode_durations, dtype=torch.float)
323 if show_result:
324 plt.title('Result')
325 else:
326 plt.clf()
327 plt.title('Training...')
328 plt.xlabel('Episode')
329 plt.ylabel('Duration')
330 plt.plot(durations_t.numpy())
331 # Take 100 episode averages and plot them too
332 if len(durations_t) >= 100:
333 means = durations_t.unfold(0, 100, 1).mean(1).view(-1)
334 means = torch.cat((torch.zeros(99), means))
335 plt.plot(means.numpy())
336
337 plt.pause(0.001) # pause a bit so that plots are updated
338 if is_ipython:
339 if not show_result:
340 display.display(plt.gcf())
341 display.clear_output(wait=True)
342 else:
343 display.display(plt.gcf())
344
345
346######################################################################

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected