How to user “Discrete“ object in openai-gym environments?

2024-09-04 18:52

本文主要是介绍How to user “Discrete“ object in openai-gym environments?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题意:怎样在 OpenAI Gym 环境中使用 “Discrete” 对象

问题背景:

I am trying to create a Q-Learning agent for a openai-gym "Blackjack-v0" environment. I am trying to get the size of the observation space but its in a form a "tuples" and "discrete" objects.

我正在尝试为 OpenAI Gym 的 "Blackjack-v0" 环境创建一个 Q-Learning 代理。我想获取观察空间的大小,但它是以“元组”和“离散”对象的形式呈现的。

All I want is to return the size of the "discrete" object. When I print "env.observation_space[0]", it returns "Discrete(32)". I've found the class on github (https://github.com/openai/gym/blob/master/gym/spaces/discrete.py), but nothing is showing how to return the integer "32" or even the value at say "env.observation_space[0][5]".

我只想返回“离散”对象的大小。当我打印 `env.observation_space[0]` 时,它返回 `Discrete(32)`。我在 GitHub 上找到了对应的类([链接](https://github.com/openai/gym/blob/master/gym/spaces/discrete.py)),但没有显示如何返回整数“32”,甚至没有显示如何获取 `env.observation_space[0][5]` 处的值。

Is there other functions I can use to return the size of the "discrete" object, and the value itself at a certain index?

我可以使用其他函数来返回“离散”对象的大小,以及在某个索引处的值吗?

Here is some code:        以下是某些代码:

print(state_size[0]) # Discrete(32)
# I want it to print 32, not Discrete(32)
print(state_size[1]) # Discrete(11)
# I want it to print 11, not Discrete(11)
print(state_size[2]) # Discrete(2)
# I want it to print 2, not Discrete(2)print(q_table[state_size[0][0]]) # TypeError: 'Discrete' object does not support indexing 
# I want to return the value of the "Discrete" object

问题解决:

In your case you can use the attribute n of Discrete object.

在你的情况下,你可以使用 `Discrete` 对象的 `n` 属性。

Example:

env.observation_space[0].n >> 32

这篇关于How to user “Discrete“ object in openai-gym environments?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1136746

相关文章

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

【Python报错已解决】AttributeError: ‘list‘ object has no attribute ‘text‘

🎬 鸽芷咕:个人主页  🔥 个人专栏: 《C++干货基地》《粉丝福利》 ⛺️生活的理想,就是为了理想的生活! 文章目录 前言一、问题描述1.1 报错示例1.2 报错分析1.3 解决思路 二、解决方法2.1 方法一:检查属性名2.2 步骤二:访问列表元素的属性 三、其他解决方法四、总结 前言 在Python编程中,属性错误(At

error while loading shared libraries: libnuma.so.1: cannot open shared object file:

腾讯云CentOS,安装Mysql时: 1.yum remove libnuma.so.1 2.yum install numactl.x86_64

java基础总结12-面向对象8(Object类)

1 Object类介绍 Object类在JAVA里面是一个比较特殊的类,JAVA只支持单继承,子类只能从一个父类来继承,如果父类又是从另外一个父类继承过来,那他也只能有一个父类,父类再有父类,那也只能有一个,JAVA为了组织这个类组织得比较方便,它提供了一个最根上的类,相当于所有的类都是从这个类继承,这个类就叫Object。所以Object类是所有JAVA类的根基类,是所有JAVA类的老祖宗

How can I load the openai api configuration through js in html?

题意:怎样在HTML中通过JavaScript加载OpenAI API配置 问题背景: I am trying to send a request through js in my html so that openai analyzes it and sends a response, but if in the js I put the following: 我正在尝试通过HTM

Creating OpenAI Gym Environment from Map Data

题意:从地图数据创建 OpenAI Gym 环境 问题背景: I am just starting out with reinforcement learning and trying to create a custom environment with OpenAI gym. However, I am stumped with trying to create an enviro

OpenAI澄清:“GPT Next”不是新模型。

不,”GPT Next” 并不是OpenAI的下一个重要项目。 本周早些时候,OpenAI 日本业务的负责人长崎忠男在日本 KDDI 峰会上分享了一场演讲,似乎在暗示一个名为 “GPT Next” 的新模型即将出现。 但OpenAI的一位发言人已向Mashable证实,幻灯片中用引号括起来的”GPT Next”一词只是一个假设性占位符,旨在表明OpenAI的模型如何随着时间呈指数级进化。发言人

某城user_dun,js逆向分析

声明: 该文章为学习使用,严禁用于商业用途和非法用途,违者后果自负,由此产生的一切后果均与作者无关。 本文章未经许可禁止转载,禁止任何修改后二次传播,擅自使用本文讲解的技术而导致的任何意外,作者均不负责,若有侵权,请联系作者立即删除! 前言 这次会简单的讲解某城ly headers中参数userdun的逆向分析流程以及简单的补环境,如果有疑问可以在评论区交流讨论,我看到会及时回复的,另外,有

user is not in the sudoers file

出现这种情况是因为用户user没有sudo权限。解决办法自然是将当前用户添加到sudo成员中。  1.以root身份登录。 2.更改文件权限:  # chmod u+w /etc/sudoers  3.在/etc/sudoers文件中,root ALL=(ALL)ALL下方添加: user ALL=(ALL)ALL 保存退出。 4.还原文件权限:  # chmod u-w /etc

王立平--Object-c

object-c通常写作objective-c或者obj-c,是根据C语言所衍生出来的语言,继承了C语言的特性,是扩充C的面向对象编程语言。它主要使用于MacOSX和GNUstep这两个使用OpenStep标准的系统,而在NeXTSTEP和OpenStep中它更是基本语言。Objective-C可以在gcc运作的系统写和编译,因为gcc含Objective-C的编译器。在MA