[英]How can I get an integer as output for continuous action space PPO reinforcement learning?
I have a huge discrete action space, the learning stability is not good.我有一个巨大的离散动作空间,学习稳定性不好。 I'd like to move to continuous action space but the only output for my task can be a positive integer (let's say in the range 0 to 999).
我想移动到连续动作空间,但我的任务唯一的 output 可以是正的 integer(假设在 0 到 999 的范围内)。 How can I force the DNN to output a positive integer?
如何强制 DNN 到 output 为正 integer?
Could you please specify which framework for RL agents you are using and which kind of environment?您能否具体说明您正在使用哪种 RL 代理框架以及哪种环境?
Assuming that you are using Stable Baselines 3 (SB3) with OpenAI gym environment, you should be able to set the desired action space when you set up the environment (see here: https://www.gymlibrary.ml/content/spaces/ ).假设您在 OpenAI 健身房环境中使用 Stable Baselines 3 (SB3),您应该能够在设置环境时设置所需的动作空间(参见此处: https://www.gymlibrary.ml/content/spaces/ )。 PPO is one of SB3's most versatile agents that can be used for "Discrete", "Box", "MultiDiscrete" and "MultiBinary" action spaces.
PPO 是 SB3 最通用的代理之一,可用于“离散”、“盒子”、“多离散”和“多二进制”动作空间。
Lastly to get an output of a positive integer only, can be achieved in several ways:最后要得到一个正 integer 的 output ,可以通过以下几种方式实现:
Box(low=-1.0, high=1.0, shape=(1,)
it would be just about scaling that output to the desired range and converting it to an int.Box(low=-1.0, high=1.0, shape=(1,)
它只是将 output 缩放到所需范围并将其转换为整数。Box(low=-1.0, high=1.0, shape=(N_DISCRETE_ACTIONS,)
and then get the final integer with a np.argmax(action)
Box(low=-1.0, high=1.0, shape=(N_DISCRETE_ACTIONS,)
然后使用np.argmax(action)
获得最终的 integerDiscrete(N_DISCRETE_ACTIONS)
Discrete(N_DISCRETE_ACTIONS)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.