# Flatten the observation without using obs\_flat

**URL:** <https://discuss.ray.io/t/flatten-the-observation-without-using-obs-flat/1077>\
**Category:** RLlib\
**Created:** [March 2, 2021, 11:12am UTC](https://discuss.ray.io/t/flatten-the-observation-without-using-obs-flat/1077 "2021-03-02T11:12:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicsteven](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/vicsteven/32/563_2.png) [@vicsteven](https://discuss.ray.io/u/vicsteven)\
**Post date:** [March 2, 2021, 11:12am UTC](https://discuss.ray.io/t/flatten-the-observation-without-using-obs-flat/1077/1 "2021-03-02T11:12:59Z")

</div>

I am trying to use a customized action mask model. I also would like to customize the flatten observation before passing it into the model. So for obs\_flat, I notice that RLlib has restore\_original\_dimensions to unpack the obs. What if I want to pack the obs? For example, I have obs with Repeated type and within the Repeated Type, it also has Dict Type. Instead of using obs\_flat and manually figure out the dimension of each different feature in obs, I want to flatten the obs in my own needs.  
‘package\_skills’: Repeated(package\_skills\_space, max\_len=self.capacity),  
‘visible\_skills’: Repeated(visible\_skills\_space, max\_len=self.max\_skill\_in\_view)  
e.g. obs = {  
‘Item1’: Repeated(Dict({‘position’: Box(-1,1,shape=(3,)), ‘value’: Discrete(5)})),  
‘Item2’: Repeated(Dict({‘position’: Box(-1,1,shape=(3,)), ‘info’: Discrete(5)})),  
}  
I want to flatten Item1 and Item2 separately so that I can feed two items separately into the model.

I first try to use the preprocessor class to do it, but it seems only work with non-tensor type. What should I do with the tensor type obs and achieve my purpose?
