# Action masking not working

**URL:** <https://discuss.ray.io/t/action-masking-not-working/11782>\
**Category:** Configure Algorithm, Training, Evaluation, Scaling\
**Created:** [August 14, 2023, 4:19pm UTC](https://discuss.ray.io/t/action-masking-not-working/11782 "2023-08-14T16:19:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobDL](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@jacobDL](https://discuss.ray.io/u/jacobDL)\
**Post date:** [August 14, 2023, 4:19pm UTC](https://discuss.ray.io/t/action-masking-not-working/11782/1 "2023-08-14T16:19:01Z")

</div>

Hello. I have been trying to set up action masking for a model I have been working on. For testing purposes I have just been trying to get any type of action masking working using the action\_mask\_model

I have been using a Discrete(50) observation space and a Discrete(50) action space. In each training step I get the current step % 50 and use that to determine the observation space and subsequently the value I want to be returned as the action (e.g step: 101 → observation value 1 and expected action value 1)

Other info: I am using PPO and the tf version of the action mask model

I have used print statements to confirm that it is definitely producing the correct observation value and action mask {0, 1, 0, 0, 0, … 0, 0}. However the action will always still return a random value between 0- 49.

I initially tested it where regardless of the step and observation it should always be masked to return 1 and this worked. I do not understand why adding variation in the mask and observation would make a difference

Side note: I have the action\_mask\_model.py saved locally with some print statements added to the forward method so I could try and debug why this may be happening. For some reason print statements only show up for the first 3 runs of forward during the build of the policy and then never again. I have even tried adding a global variable that increments when forward runs and then raised an exception when it exceeds 3 and this never gets triggered. I have been unable to understand why this is happening either
