Do we need to reset the DQN network after every episode?

I was going through this implementation of Reinforcement learning where model is being trained to manage the number of bikes at a station.

Here, line 78 represents the loop over all episodes (if I understood correctly). In line 92, the DQN Agent is defined meaning after each episode, the agent will be reset to default parameters.

But shouldn't we define the model before the loop starts because the after each episode, won't all the previous learning be lost if we initialize the class object in each iteration? Am I misinterpreting anything?

• Code doesn't look correct to me. DQN shouldn't be reinitialized every episode (there could be exception for special methods with random search but that is not the case there) – mirror2image Mar 26 '19 at 13:25
• I thought the same. But since all the results are included with visualizations which shows that model actually worked, I am in doubt what could this mean. – mayank agrawal Mar 26 '19 at 13:28
• They are not resetting the agent after every episode, that would be ridiculous, the variable called 'episodes' is clumsily chosen, it is a list of episodes that will be performed in a single training session and size of that list is number of training sessions they will perform. The real training is going on when they call train_operator method on line 98, they pass number of episodes there. – Brale Mar 26 '19 at 16:58
• Now I understand. But do we reset the agent after every session? What happens to the previous session learning? – mayank agrawal Mar 27 '19 at 6:09