# Action masking of continuous actions

**URL:** <https://discuss.ray.io/t/action-masking-of-continuous-actions/10808>\
**Category:** RLlib\
**Created:** [May 27, 2023, 10:18am UTC](https://discuss.ray.io/t/action-masking-of-continuous-actions/10808 "2023-05-27T10:18:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohit\_Modee](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rohit_modee/32/1920_2.png) [@Rohit\_Modee](https://discuss.ray.io/u/Rohit_Modee)\
**Post date:** [May 27, 2023, 10:18am UTC](https://discuss.ray.io/t/action-masking-of-continuous-actions/10808/1 "2023-05-27T10:18:07Z")

</div>

Is there an example of action masking for continuous actions?

I have the following.

obs\_space = spaces.Box(low=-1000,high=1000, shape=(30x50,))  
act\_space = spaces.Box(low=-0.05,high=0.05, shape=(30x3,))

so the 30 X 50 matrix actually is 20 X 50 and I pad the rest 10 X 50 with zeros. After that, I flatten it to get (1500,) dimension observations.

I want to add an action mask such that the model produces actions for 20 X 3 and the rest actions i.e. 10 X 3 are zero.

I am using PPO and ray2.0.0

How do I do this?

Thnx for your help in advance.

---

<div class="post-metadata">

**Author:** ![Rohit\_Modee](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rohit_modee/32/1920_2.png) [@Rohit\_Modee](https://discuss.ray.io/u/Rohit_Modee)\
**Post date:** [June 18, 2023, 10:51am UTC](https://discuss.ray.io/t/action-masking-of-continuous-actions/10808/2 "2023-06-18T10:51:50Z")

</div>

I am bumping this as there was no reply.

---

<div class="post-metadata">

**Author:** ![RolandStz](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rolandstz/32/7530_2.png) [@RolandStz](https://discuss.ray.io/u/RolandStz)\
**Post date:** [January 13, 2025, 10:11am UTC](https://discuss.ray.io/t/action-masking-of-continuous-actions/10808/3 "2025-01-13T10:11:22Z")

</div>

My suggestion would be to just define the output of the policy as 20x3 and then give a 30x3 action padded with zeros to the environment.

Does that work for you?
