Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用“用户”;离散的;openai健身房环境中的对象?_Python_Openai Gym - Fatal编程技术网

Python 如何使用“用户”;离散的;openai健身房环境中的对象?

Python 如何使用“用户”;离散的;openai健身房环境中的对象?,python,openai-gym,Python,Openai Gym,我正在尝试为openai健身房“21点-v0”环境创建一个Q-Learning代理。我试图得到观察空间的大小,但它的形式是“元组”和“离散”对象 我只想返回“离散”对象的大小。当我打印“env.observation_space[0]”时,它返回“Discrete(32)”。我在github()上找到了这个类,但是没有显示如何返回整数“32”,甚至是“env.observation_space[0][5]”处的值 是否有其他函数可用于返回“离散”对象的大小以及某个索引处的值本身 下面是一些代码:

我正在尝试为openai健身房“21点-v0”环境创建一个Q-Learning代理。我试图得到观察空间的大小,但它的形式是“元组”和“离散”对象

我只想返回“离散”对象的大小。当我打印“env.observation_space[0]”时,它返回“Discrete(32)”。我在github()上找到了这个类,但是没有显示如何返回整数“32”,甚至是“env.observation_space[0][5]”处的值

是否有其他函数可用于返回“离散”对象的大小以及某个索引处的值本身

下面是一些代码:

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

在本例中,您可以使用离散对象的属性
n

例如:

env.observation_space[0].n >> 32
env.nA >> 32

在本例中,您可以使用离散对象的属性
n

例如:

env.observation_space[0].n >> 32
env.nA >> 32

您还可以使用env对象的属性nA

例如:

env.observation_space[0].n >> 32
env.nA >> 32

env对象还具有属性nS-表示状态数。

您还可以使用env对象的属性nA

例如:

env.observation_space[0].n >> 32
env.nA >> 32

env对象还有属性nS-表示状态数。

您是否在寻找env.observation\u space.n?否,更多关于如何从“离散”对象检索信息的理解object只需使用以下内容:
action\u size=env.action\u space.n和state\u size=env.observation\u space.n
这对您很有帮助。您正在查找env.observation\u space.n吗?不,更多关于如何从“离散”数据库检索信息的理解object只需使用以下内容:
action\u size=env.action\u space.n和state\u size=env.observation\u space.n
这对您很有帮助。