def train(self, verbose=True):
        learner = self.learner
        memory = self.memory
        simulator = self.simulator

        if self.viz:
            simulator.init_viz_display()

        # run initial exploration and populate the experience replay
        self.populate_memory(self.initial_exploration) 

        # add initial observation to observatin history
        iobs = simulator.get_screenshot().copy()
        self.initial_obs(iobs)

        iteration = 0 # keeps track of all training iterations, ignores evaluation
        run_time = 0.0
        start_time = timer() # mark the global beginning of training
        last_print = timer()

        while iteration < self.iterations: # for the set number of iterations

            # perform a single simulator step
            self.step()
            # minibatch update for DQN
            if iteration % self.learn_freq == 0:
                loss, qvals = self.batch_update()
                self.iteration.append(iteration)
                self.loss.append(loss)
                self.q_ave.append(np.mean(qvals))

            if iteration % self.print_every == 0 and verbose:
                print "Iteration: %d, Loss: %.3f, Average Q-Values: %.2f, Time since print: %.2f, Total runtime: %.2f, epsilon: %.2f" % (iteration, loss, np.mean(qvals), timer() - last_print, timer() - start_time, self.epsilon)
                last_print = timer()
            
            if iteration % self.save_every == 0:
                # saving the net, the training history, and the learner itself
                learner.save_net('%s/net_%d.p' % (self.save_dir,int(iteration)))
                np.savetxt('%s/training_history.csv' % self.save_dir, np.asarray([self.iteration, self.loss, self.q_ave]).T)

            if iteration % self.eval_every == 0: # evaluation
                sim_r, sim_r_per_episode, sim_time = self.simulate(self.eval_iterations, self.eval_epsilon)
                self.eval_iteration.append(iteration)
                self.r_eval.append(sim_r)
                self.r_per_episode_eval.append(sim_r_per_episode)

                if verbose:
                    print "Evaluation, total reward: %.2f, Reward per episode: %.2f" % (sim_r, sim_r_per_episode)

                np.savetxt('%s/evaluation_history.csv' % self.save_dir, np.asarray([self.eval_iteration, self.r_eval, self.r_per_episode_eval]).T)

            if iteration % self.target_net_update == 0:
                learner.copy_net_to_target_net()

            self.epsilon -= self.epsilon_decay
            self.epsilon = 0.1 if self.epsilon < 0.1 else self.epsilon

            iteration += 1

        memory.close()

        learner.save_net('%s/net_%d.p' % (self.save_dir,int(iteration)))
        np.savetxt('%s/training_history.csv' % self.save_dir, np.asarray([self.iteration, self.loss, self.q_ave]).T)

        run_time = timer() - start_time
        print('Overall training + evaluation time: '+ str(run_time))
Trains the network
dataset/ETHPy150Open sisl/Chimp/chimp/agents/dqn_agent.py/DQNAgent.train