如何使观察在自定义Pyenvronment中
In the 用于TF-Agent Environments的TensorFlow文档有一个简单(二十一点启发)卡游戏的环境的示例。
__ INIT __
看起来如下:
class CardGameEnv(py_environment.PyEnvironment):
def __init__(self):
self._action_spec = array_spec.BoundedArraySpec(
shape=(), dtype=np.int32, minimum=0, maximum=1, name='action')
self._observation_spec = array_spec.BoundedArraySpec(
shape=(1,), dtype=np.int32, minimum=0, name='observation')
self._state = 0
self._episode_ended = False
但是,如果我的观察结果不能以数字而表达而需要一个字符串,该怎么办?我不能简单地指定dtype = str
或dtype = pd.str
,因为有min/max属性:
TypeError: Cannot find minimum value of <dtype: 'string'> with type <dtype: 'string'>.
In call to configurable 'BoundedArraySpec' (<class 'tf_agents.specs.array_spec.BoundedArraySpec'>)
有人有任何想法吗?
In the tensorflow documentation for TF-Agents Environments there is an example of an environment for a simple (blackjack inspired) card game.
The __init__
looks like the following:
class CardGameEnv(py_environment.PyEnvironment):
def __init__(self):
self._action_spec = array_spec.BoundedArraySpec(
shape=(), dtype=np.int32, minimum=0, maximum=1, name='action')
self._observation_spec = array_spec.BoundedArraySpec(
shape=(1,), dtype=np.int32, minimum=0, name='observation')
self._state = 0
self._episode_ended = False
But what if my observation can't be expressed as a number but needs a string? I can't simply specify dtype=str
or dtype=pd.str
because of the min/max attributes:
TypeError: Cannot find minimum value of <dtype: 'string'> with type <dtype: 'string'>.
In call to configurable 'BoundedArraySpec' (<class 'tf_agents.specs.array_spec.BoundedArraySpec'>)
Anyone got any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论