我正在通过Jupyter(Ubuntu 14.04)在p2.xlarge AWS服务器上运行python 2.7脚本.我希望能够渲染我的模拟.
最小的工作示例
import gym
env = gym.make('CartPole-v0')
env.reset()
env.render()
Run Code Online (Sandbox Code Playgroud)
env.render() 使(除其他外)以下错误:
...
HINT: make sure you have OpenGL install. On Ubuntu, you can run
'apt-get install python-opengl'. If you're running on a server,
you may need a virtual frame buffer; something like this should work:
'xvfb-run -s \"-screen 0 1400x900x24\" python <your_script.py>'")
...
NoSuchDisplayException: Cannot connect to "None"
Run Code Online (Sandbox Code Playgroud)
我想有些人能够看到模拟.如果我可以将它内联,那将是理想的,但任何显示方法都会很好.
编辑:这只是某些环境的问题,如经典控件.
更新我
灵感来自这个我尝试以下,而不是xvfb-run -s \"-screen 0 1400x900x24\" python <your_script.py>(我不能去上班).
xvfb-run -a jupyter …Run Code Online (Sandbox Code Playgroud) 我使用的是Windows 10,Python 3.5和tensorflow 1.1.0.我有以下脚本:
import tensorflow as tf
import tensorflow.contrib.keras.api.keras.backend as K
from tensorflow.contrib.keras.api.keras.layers import Dense
tf.reset_default_graph()
init = tf.global_variables_initializer()
sess = tf.Session()
K.set_session(sess) # Keras will use this sesssion to initialize all variables
input_x = tf.placeholder(tf.float32, [None, 10], name='input_x')
dense1 = Dense(10, activation='relu')(input_x)
sess.run(init)
dense1.get_weights()
Run Code Online (Sandbox Code Playgroud)
我收到错误: AttributeError: 'Tensor' object has no attribute 'weights'
我想访问SequentialKeras模型中所有图层的图层大小.我的代码:
model = Sequential()
model.add(Conv2D(filters=32,
kernel_size=(3,3),
input_shape=(64,64,3)
))
model.add(MaxPooling2D(pool_size=(3,3), strides=(2,2)))
Run Code Online (Sandbox Code Playgroud)
然后我想像下面的代码一样工作
for layer in model.layers:
print(layer.get_shape())
Run Code Online (Sandbox Code Playgroud)
..但它没有.我收到错误:AttributeError: 'Conv2D' object has no attribute 'get_shape'
我想在OpenAI CarRacing-v0环境中设置RL代理,但在此之前我想了解动作空间.在github上的代码中, 119行说:
self.action_space = spaces.Box( np.array([-1,0,0]), np.array([+1,+1,+1])) # steer, gas, brake
Run Code Online (Sandbox Code Playgroud)
我该如何阅读这一行?虽然我的问题是具体的,但CarRacing-v0我想了解spaces.Box()一般的符号
我想知道如何\usepackage{}在Jupyter笔记本中使用LaTeX.
我正在寻找一种简单的方法来验证我的TF图表实际上是在GPU上运行.
PS.验证cuDNN库是否被使用也是很好的.
我最近在Windows 10(x64)上使用Anaconda安装了Python 2.7
我正在尝试安装Theano,但我不知道应该在哪里放置'.theanorc'文件(用于设置Theano参数).我已经证实theano工作(训练的小神经网络).
我试图把它放在C:\Anaconda(在哪里python.exe和\Lib\os.py所在位置),但它看起来并不像theano注册它.
我的.theanorc档案
[global]
floatX=float32
Run Code Online (Sandbox Code Playgroud)
当我输入
>>> import theano; print(theano.config)
Run Code Online (Sandbox Code Playgroud)
我明白了
...
floatX (('float64', 'float32', 'float16'))
Doc: Default floating-point precision for python casts.
Note: float16 support is experimental, use at your own risk.
Value: float64
...
Run Code Online (Sandbox Code Playgroud) 我想在CartPole-v0不打开渲染窗口的情况下访问 OpenAI 健身房环境中的原始像素。我该怎么做呢?
示例代码:
import gym
env = gym.make("CartPole-v0")
env.reset()
img = env.render(mode='rgb_array', close=True) # Returns None
print(img)
img = env.render(mode='rgb_array', close=False)
# Opens annoying window, but gives me the array that I want
print(img.shape)
Run Code Online (Sandbox Code Playgroud)
附注。我很难为 OpenAI 健身房找到好的文档。它只是我,还是根本不存在?
编辑:我不需要打开渲染视频。
我的 Windows 上有一个 PyCharm 项目,我可以.py通过按Ctrl + Shift + F10(或运行调试器)来运行大多数文件。但是在其中一个文件中我收到错误
Run Code Online (Sandbox Code Playgroud)Error running 'test': Cannot run program "\opt\anaconda\bin\python" (in directory "..."): CreateProcess error=2, the system cannot find the file specified.`
该test.py文件现在只包含print('hello')
我可以对其他文件执行此操作,并且使用“在控制台中执行选择”也可以正常工作。鉴于我使用的是 Windows 计算机,该"\opt\anaconda\bin\python"部分看起来很可疑,但我不知道如何修复它。
有什么帮助吗?
将内容复制到另一个文件(例如test_2.py)“修复”问题,但由于这是一个协作项目,因此这是不可行的。
python ×5
tensorflow ×4
openai-gym ×3
keras ×2
theano ×2
anaconda ×1
cudnn ×1
gpu ×1
keras-layer ×1
latex ×1
pycharm ×1
pyglet ×1
python-2.7 ×1
python-3.5 ×1
windows ×1
xvfb ×1