- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对下面提供的代码有一些问题。我正在研究 python 3.6。我已经重新安装了 Python 和运行代码所需的所有模块。总的来说,我所做的一切都是基于这个tutorial .
当我运行此代码时,我收到以下警告并且根本没有输出。我不明白这些警告的含义以及如何解决它。我将不胜感激任何帮助。
Warning (from warnings module): File "D:\Users\Rafal\AppData\Local\Programs\Python\Python36\lib\site packages\h5py__init__.py", line 36 from ._conv import register_converters as _register_converters FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type
还有:
[33mWARN: gym.spaces.Box autodetected dtype as . Please provide explicit dtype.[0m
我运行的代码:
import gym
import random
import numpy as np
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
from statistics import median, mean
from collections import Counter
LR = 1e-3
env = gym.make("CartPole-v0")
env.reset()
goal_steps = 500
score_requirement = 50
initial_games = 10000
def initial_population():
# [OBS, MOVES]
training_data = []
# all scores:
scores = []
# just the scores that met our threshold:
accepted_scores = []
# iterate through however many games we want:
for _ in range(initial_games):
score = 0
# moves specifically from this environment:
game_memory = []
# previous observation that we saw
prev_observation = []
# for each frame in 200
for _ in range(goal_steps):
# choose random action (0 or 1)
action = random.randrange(0,2)
# do it!
observation, reward, done, info = env.step(action)
# notice that the observation is returned FROM the action
# so we'll store the previous observation here, pairing
# the prev observation to the action we'll take.
if len(prev_observation) > 0 :
game_memory.append([prev_observation, action])
prev_observation = observation
score+=reward
if done: break
# IF our score is higher than our threshold, we'd like to save
# every move we made
# NOTE the reinforcement methodology here.
# all we're doing is reinforcing the score, we're not trying
# to influence the machine in any way as to HOW that score is
# reached.
if score >= score_requirement:
accepted_scores.append(score)
for data in game_memory:
# convert to one-hot (this is the output layer for our neural network)
if data[1] == 1:
output = [0,1]
elif data[1] == 0:
output = [1,0]
# saving our training data
training_data.append([data[0], output])
# reset env to play again
env.reset()
# save overall scores
scores.append(score)
# just in case you wanted to reference later
training_data_save = np.array(training_data)
np.save('saved.npy',training_data_save)
# some stats here, to further illustrate the neural network magic!
print('Average accepted score:',mean(accepted_scores))
print('Median score for accepted scores:',median(accepted_scores))
print(Counter(accepted_scores))
return training_data
最佳答案
要回答与此错误有关的第二个问题:
gym.spaces.Box autodetected dtype as <class 'numpy.float32'>
转到下载的“gym”文件的目录。进入gym/spaces/并打开“box.py”文件。
在第 12 行附近,您应该看到:
def __init__(self,low.shape=None,high.shape=None,shape=None,dtype=None):
将dtype=None
更改为dtype=np.float32
这为我解决了错误。
关于python - 使用 Gym 训练神经网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49218443/
关注 this (不可读)论坛帖子,我认为将其发布在堆栈溢出上以供后代搜索它是合适的。 如何在 init 上为健身房环境传递参数? 最佳答案 同时支持 gym.make 中的论点已实现,因此您可以将关
调用 env.render() 总是渲染一个充满整个屏幕的窗口。 env = gym.make('FetchPickAndPlace-v1') env.reset() for i in range(1
我正在查看FrozenLake environments在露天健身房。在这两种方法中,在智能体达到目标之前,都没有奖励,甚至没有负奖励。即使特工掉进冰里,也没有负面奖励——尽管情节结束了。没有奖励,就
我已经尝试使用健身房几周了。然而,我没有成功。我正在尝试运行 CartPole 的此实现,但收到返回错误: NotImplementedError:抽象 据我所知,我已经安装了健身房。但是,无论出于何
我使用的是 WSL2 和 Ubuntu 20.4,我使用 (venv) 创建了一个全新的虚拟环境,并按照 OpenAI 官方页面的说明 (https://retro.readthedocs.io/en
我使用的是 WSL2 和 Ubuntu 20.4,我使用 (venv) 创建了一个全新的虚拟环境,并按照 OpenAI 官方页面的说明 (https://retro.readthedocs.io/en
是否可以让 faSTLane gym Action 跳过存档和导出到 IPA?例如,如果您只是在 CI 服务器上构建验证,并且不需要输出,而只想验证编译和测试步骤。 最佳答案 你应该检查scan :
所以我刚刚开始使用 OpenAI 的 Gym,并尝试在控制台中渲染环境。具体来说,它是 Taxi-v2 环境。在它应该显示颜色的地方,它只显示符号(我认为是它们的 ANSI 代码),所以我相信它没有正
我正在 OpenAI Gym 中制作自定义环境,但真的不明白,action_space 是做什么用的?我应该在里面放什么?准确地说,我不知道 action_space 是什么,我没有在任何代码中使用它
我创建了一个自定义健身房环境,其中的操作可以是 -100 到 +100 之间的任何整数。据我所知,不可能创建一个允许负值的离散空间,我唯一的解决方案是创建一个从 -100 到 +100 的 Box 空
我对下面提供的代码有一些问题。我正在研究 python 3.6。我已经重新安装了 Python 和运行代码所需的所有模块。总的来说,我所做的一切都是基于这个tutorial . 问题描述: 当我运行此
除了 openAI's doc ,我没能找到更详细的文档。 我需要知道正确的创建方法: 一个具有 1..n 个可能操作的操作空间。 (当前使用离散 Action 空间) 具有 2^n 状态的观察空间
我们有多个构建使用不同的应用程序 ID、配置文件和团队(一个团队 ID 是官方的,另一个是企业的)。我试图将它们放在 Gymfile 中,因为 faSTLane 无法弄清楚配置文件。 Gymfile
我已阅读 https://codesigning.guide/但决定不使用此解决方案来存储我的配置文件,而是将它们存储在每个项目的 git 中。 对于我的项目,我在我的 xconfig 文件中指定了我
我想知道在 OpenAI Gym( https://gym.openai.com/ ) 中观察 CartPole-v0 的规范。 例如,在下面的代码中输出observation。一种观察结果类似于 [
我正在尝试在 WSL 上使用来自 OpenAI 的著名“健身房”模块,并在 python 3.5.2 上执行代码。 当我尝试运行环境时 as explained here ,使用代码: import
从头开始构建 OpenAI Gym 环境时,必须定义一个 Action 空间。这是通过数据包“空间”中的自己的“数据结构”完成的。有几种不同类型的空间,如 Box、Discrete 等。我有一个元组列
如果我们查看环境的预览,它们会在右下角的动画中显示剧集的增加。 https://gym.openai.com/envs/CartPole-v1/ .是否有明确显示的命令? 最佳答案 我认为 Ope
我正在尝试运行 OpenAI Gym 环境,但是出现以下错误: import gym env = gym.make('Breakout-v0') 错误 /Library/Frameworks/Pyth
我想知道是否有人知道是否有教程或任何有关如何从 openai 健身房修改 CarRacing-v0 环境的信息,更确切地说是如何创建不同的道路,我还没有找到任何相关信息。 我想要做的就是创建一条更难的
我是一名优秀的程序员,十分优秀!