深度强化学习训练精度

我正在使用深度强化学习方法来预测时间序列行为。由于我是这方面的初学者,我的提问更多是概念性的,而非计算机编程问题。我的同事给了我以下图表,展示了使用深度强化学习对时间序列数据进行分类的训练、验证和测试精度。

enter image description here

从这个图表中可以看出,验证和测试的精度都是随机的,因此,显然代理存在过拟合现象。

但让我更惊讶的是(可能是因为缺乏知识,所以我在这里提问),我的同事是如何训练他的代理的。在这个图表的X轴上,你可以看到“epoch”数(或迭代)。换句话说,代理被多次拟合(或训练),如下面的代码所示:

#initiating the agentself.agent = DQNAgent(model=self.model, policy=self.policy, nb_actions=self.nbActions, memory=self.memory, nb_steps_warmup=200, target_model_update=1e-1, enable_double_dqn=True,enable_dueling_network=True)#Compile the agent with the Adam optimizer and with the mean absolute error metricself.agent.compile(Adam(lr=1e-3), metrics=['mae'])#there will be 100 iterations, I will fit and test the agent 100 timesfor i in range(0,100):    #delete previous environments and create new ones             del(trainEnv)           trainEnv = SpEnv(parameters)    del(validEnv)    validEnv=SpEnv(parameters)    del(testEnv)    testEnv=SpEnv(parameters)   #Reset the callbacks used to show the metrics while training, validating and testing   self.trainer.reset()   self.validator.reset()   self.tester.reset()   ####TRAINING STEP####    #Reset the training environment   trainEnv.resetEnv()   #Train the agent   self.agent.fit(trainEnv,nb_steps=floor(self.trainSize.days-self.trainSize.days*0.2),visualize=False,verbose=0)   #Get metrics from the train callback     (metrics)=self.trainer.getInfo()   #################################   ####VALIDATION STEP####   #Reset the validation environment   validEnv.resetEnv()   #Test the agent on validation data   self.agent.test(validEnv,other_parameters)   #Get the info from the validation callback   (metrics)=self.validator.getInfo()   ####################################                ####TEST STEP####   #Reset the testing environment   testEnv.resetEnv()   #Test the agent on testing data               self.agent.test(testEnv,nb_episodes=floor(self.validationSize.days-self.validationSize.days*0.2),visualize=False,verbose=0)   #Get the info from the testing callback   (metrics)=self.tester.getInfo()

根据图表和代码,我感到奇怪的是,代理被多次独立拟合,但训练精度随时间增加。似乎之前的经验在帮助代理提高训练精度。但如果环境被重置,并且代理只是再次拟合,为什么会这样呢?是否有来自之前拟合的误差反向传播,帮助代理在下一次拟合中提高精度?


回答:

被重置的是环境,而不是代理。因此,代理实际上是从每次迭代中积累经验的。

Related Posts

Keras Dense层输入未被展平

这是我的测试代码: from keras import…

无法将分类变量输入随机森林

我有10个分类变量和3个数值变量。我在分割后直接将它们…

如何在Keras中对每个输出应用Sigmoid函数?

这是我代码的一部分。 model = Sequenti…

如何选择类概率的最佳阈值?

我的神经网络输出是一个用于多标签分类的预测类概率表: …

在Keras中使用深度学习得到不同的结果

我按照一个教程使用Keras中的深度神经网络进行文本分…

‘MatMul’操作的输入’b’类型为float32,与参数’a’的类型float64不匹配

我写了一个简单的TensorFlow代码,但不断遇到T…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注