擅长:python、mysql、java
<p>您要求的“多个一个热”空间已经实现</p>
<p><a href="https://github.com/openai/gym/blob/master/gym/spaces/multi_binary.py" rel="nofollow noreferrer">https://github.com/openai/gym/blob/master/gym/spaces/multi_binary.py</a></p>
<pre><code>import gym
# create a MultiBinary Space
# by passing n=10, each sample will contain 10 elements
mb = gym.spaces.MultiBinary(n=10)
mb.sample()
# array([1, 0, 1, 0, 0, 0, 0, 0, 0, 1], dtype=int8)
</code></pre>
<p>如果您想实现自己的索引,以确保在调用<code>sample</code>时没有超过一定数量的正元素,那么可以从<em>n</em>选项中随机选择<em>x</em>索引,然后在所有<code>0</code>数组中翻转这些索引,然后返回该值。在</p>