【问题标题】:Tensorflow 2.x Agents(TF-Agents, Reinforcement Learning Module) & PySC2Tensorflow 2.x Agents(TF-Agents, Reinforcement Learning Module) & PySC2
【发布时间】:2021-02-26 08:54:36
【问题描述】:

有pysc2(https://github.com/deepmind/pysc2)&Tensorflow(1.x)和OpenAI-Baselines(https://github.com/openai/baselines),如下

https://github.com/chris-chris/pysc2-examples
https://github.com/llSourcell/A-Guide-to-DeepMinds-StarCraft-AI-Environment

TF 团队最近提出了一个名为 TF-Agents (https://github.com/tensorflow/agents) 的 RL 实现(OpenAi-Baselines 的替代方案)。 例子:

https://github.com/tensorflow/agents/blob/master/docs/tutorials/1_dqn_tutorial.ipynb
https://github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class_12_05_apply_rl.ipynb
https://github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class_12_04_atari.ipynb

对于 TF-Agent,您可以这样做

env_name = 'CartPole-v0'
train_py_env = suite_gym.load(env_name)
eval_py_env = suite_gym.load(env_name)

q_net = q_network.QNetwork(
    train_env.observation_spec(),
    train_env.action_spec(),
    fc_layer_params=fc_layer_params)

optimizer = tf.compat.v1.train.AdamOptimizer(learning_rate=learning_rate)

agent = dqn_agent.DqnAgent(
    train_env.time_step_spec(),
    train_env.action_spec(),
    q_network=q_net,
    optimizer=optimizer,
    td_errors_loss_fn=common.element_wise_squared_loss,
    train_step_counter=train_step_counter)
agent.initialize()

对于 pysc2,

from pysc2.env import environment
from pysc2.env import sc2_env
from pysc2.lib import actions
from pysc2.lib import actions as sc2_actions
from pysc2.lib import features
mineral_env = sc2_env.SC2Env(
        map_name="CollectMineralShards",
        step_mul=step_mul,
        agent_interface_format=AGENT_INTERFACE_FORMAT,
        visualize=True)

如何将 TF-Agents 和 Pysc2 结合在一起? 它们都是 Google 产品。

【问题讨论】:

    标签: tensorflow2.0 reinforcement-learning tensorflow-agents starcraftgym


    【解决方案1】:

    我最近偶然发现了一个非常相似的情况,我想将 DeepMind 开发的 hanabi-learning-environment 与 TF-Agents 一起使用。恐怕我不得不说没有很好的解决方案。

    您必须做的是派生 DeepMind 存储库并修改环境包装器以与 TF-Agents 的要求兼容。这将是一项相当多的工作,尤其是如果您不熟悉 TF-Agents 中如何定义环境,但这绝对可以在大约一周的工作中完成。

    如果您想了解我所做的事情,可以查看 DeepMind 的 Hanabi 存储库中的原始 rl_env.py 代码,以及我在 repo 中对其进行的修改

    我不知道为什么 DeepMind 坚持他们的结构而不是让他们的代码更兼容,但事实就是这样。

    【讨论】:

      猜你喜欢
      • 2019-12-25
      • 1970-01-01
      • 2021-05-03
      • 2021-05-11
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 2021-10-21
      • 2021-09-15
      相关资源
      最近更新 更多