软件风向标,重度软件行业发展门户!

文章更新 | 热门文章
您的位置: 首页  →  攻略 → 《progress游戏攻略84 hogwartsstory游戏攻略

progress游戏攻略84 hogwartsstory游戏攻略

2023-06-03 20:27:53      小编:      我要评论

报道机器之心

参与:Racoon X

还是熟悉的覆盆子派! RL agent 打 Atari 不再需要 GPU 集群,这个项目让你在边缘设备上进行实时训练。

自从 DeepMind 团队提出 DQN,在 Atari 在游戏中展示超人技能已经很久了。在此期间,不断提出和创造新的方法 Deep RL 领域新 SOTA。然而,目前,无论是同一策略还是不同的策略来加强学习方法(这里只是没有模型) RL),仍然需要强大的算力予以支撑。即使研究人员已经将就 Atari 游戏分辨率降低到 84x一般情况下仍需使用84 GPU 战略训练。

如今,来自 Ogma Intelligent Systems Corp. 研究人员突破了这一限制。稀疏预测阶级机制(Sparse Predictive Hierarchies)在此基础上,提出了不需要反传机制的战略搜索框架,使树莓实时训练 Atari 游戏的控制策略是可能的。下图显示了使用该算法在树莓派上进行实时训练的情况。

可以看到,agent 学会了如何正确调整滑块位置来抓住球并发动进攻策略。值得注意的是,观察输入为每时每刻产生的图片。

也就是说,该算法实现了从像素到策略的映射关系,如树莓派。

研究人员开源于他们 SPH 实现代码并提供相应的机制 Python API。这是一个结合动态系统应用数学、计算神经科学和机器学习的扩展库。他们的方法曾经被用过 MIT 列出科技评论「Best of the Physics arXiv」。

项目地址:

https://github.com/ogmacorp/OgmaNeo2

OgmaNeo2

研究人员提出的 SPH 机制不仅在 Pong 表现良好,在连续战略领域也表现良好。下图分别使用该算法 OpenAI gym 中 Lunar Lander 环境与 PyBullet 中四足机器人环境的训练结果。

在 Lunar Lander 在环境中,训练 1000 代后,每一个 episode 下 agent 取得了平均 100 分左右的 reward。若训练时间较长(30000 代以上),agent 的平均 reward 甚至能达到 200。在 PyBullet 的 Minitaur 环境中,agent 训练目标是在自身能量限制下跑得越快越好。从图中可以看出,经过一段时间的训练,这个四足机器人学会了保持身体平衡,快速奔跑(它的步态看起来不那么自然)。看起来效果还是很好的,机器之心也开始测试。

算法框架

OgmaNeo2 用来学习 Pong 控制策略的整体框架如下图所示。图像观测值通过图像编码器输入两层 exponential memory 在结构中,输出计算结果 RL 层产生相应的动作策略。

项目实测

在安装 PyOgmaNeo2 在此之前,我们需要编译和安装相应的 C 库。将 OgmaNeo2 克隆到本地:

!git clone https://github.com/ogmacorp/OgmaNeo2.git

然后将工作目录切换到 OgmaNeo2 下面,在其中创建一个名字 build 存储编译过程中生成的文件夹。

import os

os.chdir('OgmaNeo2')

!mkdir build

os.chdir('build')

接下来,我们是对的 OgmaNeo2 编译。值得注意的是,我们需要-DBUILD_SHARED_LIBS=ON 命令传入 cmake 只有这样,我们才能在未来 PyOgmaNeo2 扩展库中使用它。

!cmake .. -DBUILD_SHARED_LIBS=ON

!make

!make install

当 OgmaNeo2 安装成功后,安装 SWIG v3 及 OgmaNeo2 的相应 Python 扩展库:

!apt-get install swig3.0

os.chdir('/content')

!git clone https://github.com/ogmacorp/PyOgmaNeo2

os.chdir('PyOgmaNeo2')

!python3 setup.py install --user

接下来输入 import pyogmaneo,如果没有错误的提示,则表明已成功安装 PyOgmaNeo2。

先用官方提供的时间序列回归来测试一下,在 notebook 中输入:

import numpy as np

import pyogmaneo

import matplotlib.pyplot as plt

# Set the number of threads

pyogmaneo.ComputeSystem.setNumThreads(4)

# Create the compute system

cs = pyogmaneo.ComputeSystem()

# This defines the resolution of the input encoding - we are using a simple single column that represents a bounded scalar through a one-hot encoding. This value is the number of "bins"

inputColumnSize = 64

# The bounds of the scalar we are encoding (low, high)

bounds = (-1.0, 1.0)

# Define layer descriptors: Parameters of each layer upon creation

lds = []

for i in range(5): # Layers with exponential memory

ld = pyogmaneo.LayerDesc()

# Set the hidden (encoder) layer size: width x height x columnSize

ld.hiddenSize = pyogmaneo.Int3(4, 4, 16)

ld.ffRadius = 2 # Sparse coder radius onto visible layers

ld.pRadius = 2 # Predictor radius onto sparse coder hidden layer (and feed back)

ld.ticksPerUpdate = 2 # How many ticks before a layer updates (compared to previous layer) - clock speed for exponential memory

ld.temporalHorizon = 2 # Memory horizon of the layer. Must be greater or equal to ticksPerUpdate, usually equal (minimum required)

lds.append(ld)

# Create the hierarchy: Provided with input layer sizes (a single column in this case), and input types (a single predicted layer)

h = pyogmaneo.Hierarchy(cs, [ pyogmaneo.Int3(1, 1, inputColumnSize) ], [ pyogmaneo.inputTypePrediction ], lds)

# Present the wave sequence for some timesteps

iters = 2000

for t in range(iters):

# The value to encode into the input column

valueToEncode = np.sin(t * 0.02 * 2.0 * np.pi) * np.sin(t * 0.035 * 2.0 * np.pi 0.45) # Some wavy line

valueToEncodeBinned = int((valueToEncode - bounds[0]) / (bounds[1] - bounds[0]) * (inputColumnSize - 1) 0.5)

# Step the hierarchy given the inputs (just one here)

h.step(cs, [ [ valueToEncodeBinned ] ], True) # True for enabling learning

# Print progress

if t % 100 == 0:

print(t)

# Recall the sequence

ts = [] # Time step

vs = [] # Predicted value

trgs = [] # True value

for t2 in range(300):

t = t2 iters # Continue where previous sequence left off

# New, continued value for comparison to what the hierarchy predicts

valueToEncode = np.sin(t * 0.02 * 2.0 * np.pi) * np.sin(t * 0.035 * 2.0 * np.pi 0.45) # Some wavy line

# Bin the value into the column and write into the input buffer. We are simply rounding to the nearest integer location to "bin" the scalar into the column

valueToEncodeBinned = int((valueToEncode - bounds[0]) / (bounds[1] - bounds[0]) * (inputColumnSize - 1) 0.5)

# Run off of own predictions with learning disabled

h.step(cs, [ [ valueToEncodeBinned ] ], False) # Learning disabled

predIndex = h.getPredictionCs(0)[0] # First (only in this case) input layer prediction

# Decode value (de-bin)

value = predIndex / float(inputColumnSize - 1) * (bounds[1] - bounds[0]) bounds[0]

# Append to plot data

ts.append(t2)

vs.append(value)

trgs.append(valueToEncode)

# Show predicted value

print(value)

# Show plot

plt.plot(ts, vs, ts, trgs)

可以得到以下结果。图中橙色曲线为真实值,蓝色曲线为预测值。由此可见,该方法以极小的误差拟合了真实曲线。

最后,项目在 CartPole 任务中的表现。python3 ./examples/CartPole.py,获得以下训练结果。可以看出,它只使用 150 个 episode 左右解决 CartPole 任务。

游戏攻略[共2205款]

progress[共1款]

hogwartsstory[共3款]

  • 发表评论
资讯排行 资讯中心 热门专区 软件评测
软件排行榜 软件攻略 软件下载 软件开测表
软件排行榜 软件礼包 软件下载 新软件测表
安卓排行榜 软件视频 软件下载
苹果排行榜