[英]How to output an array as actions in a Deep Reinforcement Learning Model?
我目前正在開發自定義多代理 DQN 環境,我的 action_space 是一個列表,例如 [2,4,3,2,1]。
其中 actionlist[0] 是第一個代理采取的行動,actionlist[1] 是第二個代理采取的行動,依此類推。
通常對於單個值 output,代碼將如下所示:
states = env.observation_space.shape
actions = env.action_space.n
def build_model(states, actions):
model = Sequential()
model.add(Dense(24, activation='relu', input_shape=states))
model.add(Dense(24, activation='relu'))
model.add(Dense(actions, activation='linear'))
return model
...some model building
def build_agent(model, actions):
policy = BoltzmannQPolicy()
memory = SequentialMemory(limit=50000, window_length=1)
dqn = DQNAgent(model=model, memory=memory, policy=policy,
nb_actions=actions, nb_steps_warmup=10, target_model_update=1e-2)
return dqn
但是,這不適用於不是單個值的 output。
go怎么辦呢?
首先你需要知道有兩種類型的動作空間問題(離散和連續)和兩種類型的強化學習方法(1.value-based 和 2.policy or policy/value based)。
DQN 是基於價值的強化學習方法,它計算任何給定 state 向量處每個離散動作的價值。 因此,它僅針對離散動作空間問題而設計(例如,動作可以是向量 [1,2,3] 中的一個值)。
您描述中的“不是單個值”動作是一個連續的動作空間問題,您的動作可以是給定范圍內的任何可能值(例如,[0,10] 范圍內的 2.0120321)。 對於連續動作空間問題,需要使用基於策略的強化學習方法,例如 Actor-Critic 和其他建立在 actor-critic 之上的流行框架,如 PPO、DDPG 等。
我建議您通過閱讀 Richard Sutton 在該領域最流行的教科書(強化學習:簡介)來了解強化學習的一些基本概念: https://web.stanford.edu/class/psych209/Readings/SuttonBartoIPRLBook2ndEd。 pdf
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.