在我的PPO模型中,我希望在整个训练过程中逐渐减少clip_range (探索与开发参数)。
我尝试过简单地运行"model.clip_range = new_value",但这是行不通的。
在docs 这里中,它表示"clip_range (clip_range[clip_range,可调用的[float,float])-裁剪参数,它可以是当前剩余进度的函数(从1到0)“。
是否有人知道如何在培训期间实际更改此参数,或者如何输入“当前进度的函数”?
发布于 2022-06-29 17:09:50
我已经解决了这个问题。
您需要有一个稍微时髦的设置,其中一个函数输出另一个函数。在此链接,他们给出了以下示例:
def linear_schedule(initial_value):
"""
Linear learning rate schedule.
:param initial_value: (float or str)
:return: (function)
"""
if isinstance(initial_value, str):
initial_value = float(initial_value)
def func(progress):
"""
Progress will decrease from 1 (beginning) to 0
:param progress: (float)
:return: (float)
"""
return progress * initial_value
return func因此,从本质上讲,您必须编写一个函数myscheduler(),它不一定需要输入,并且需要将该函数的输出作为另一个函数,它具有“进度”(随着培训的进行从1到0)为唯一的输入。这个“进度”值将由PPO本身传递给函数。所以,我认为“幕后”的顺序是这样的:
在我的例子中,我写了这样的东西:
def lrsched():
def reallr(progress):
lr = 0.003
if progress < 0.85:
lr = 0.0005
if progress < 0.66:
lr = 0.00025
if progress < 0.33:
lr = 0.0001
return lr
return reallr然后,以下列方式使用该函数:
model = PPO(...learning_rate=lrsched())https://stackoverflow.com/questions/72483775
复制相似问题