简体   繁体   中英

Simulation and visualization libraries for reinforcement learning in python?

I am aware of keras, block na few others Python libraries for nn which do RL among others. But is there a library than can make the task of visualizations easy? In terms of 3D model of agents/environment,Seeing the simulations etc... I can see a few RL videos online that show the simulated agent/environment but either they have made visual models from the ground up or used some other language/technology...(or they are very old)

Generally speaking that is the difference between a 3D visualization library and 3D scientific visualization library which has a more "high-level" approach to visualization than the prior (direct calls to a scatterplot, surface, and so on).

Since you did not specify an actual example of what you want to plot I can only provide viable libraries that are considered simple (considering the 3D lib universe of Python).

One is VPython which has very explicit syntax towards 3D primitives . This would be a valid code for building a sphere and a box:

from visual import *
ball = sphere(pos=(-5,0,0), radius=0.5, color=color.cyan)
wallR = box(pos=(6,0,0), size=(0.2,12,12), color=color.green)

If your simulation rely on very well defined objects like images, surfaces, scattered points and so on you might want to take a look at the 3D capabilities of matplotlib :

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
xs = np.random.randint(0,100,100)
ys = np.random.randint(0,100,100)
zs = np.random.randint(0,100,100)
ax.scatter(xs, ys, zs, c=c)
plt.show()

Also Mayavi has a lot of high level calls to well know plots (but I think at the date I'm writing this is still not available in Python 3, someone correct me if I'm wrong):

import numpy
from mayavi.mlab import *

def test_surf():
    """Test surf on regularly spaced co-ordinates like MayaVi."""
    def f(x, y):
        sin, cos = numpy.sin, numpy.cos
        return sin(x + y) + sin(2 * x - y) + cos(3 * x + 4 * y)

    x, y = numpy.mgrid[-7.:7.05:0.1, -5.:5.05:0.05]
    s = surf(x, y, f)
    #cs = contour_surf(x, y, f, contour_z=0)
    return s

Mayavi itself is based on VTK which also has a Python API. Other relevant libraries are:

  • pyQtGraph : very good if you want to embed your visualization (2D and 3D) in PySide or PyQt.
  • Glumpy
  • Vispy : It's still very new but I'm expecting great things from this library. If memory does not fail me It's being made by the same people who brought use libraries such as pyQtGraph, Glumpy and Galry.
  • Galry

There are others like the bindings for OpenSceneGraph , OpenGL or Coin3D but many are badly documented, or with a very tough learning curve.

As an extra you might also want to consider Blender since you can use Python inside and it has a very rich environment for 3D modeling.

可能您对OpenAI GymMuJoCo进行3D环境模拟/可视化感兴趣。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM