# Multiple equals

**URL:** <https://discuss.pytorch.org/t/multiple-equals/153584>\
**Category:** Uncategorized\
**Created:** [June 7, 2022, 5:01pm UTC](https://discuss.pytorch.org/t/multiple-equals/153584 "2022-06-07T17:01:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shon711](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/eada6e/32.png) [@shon711](https://discuss.pytorch.org/u/shon711)\
**Post date:** [June 7, 2022, 5:01pm UTC](https://discuss.pytorch.org/t/multiple-equals/153584/1 "2022-06-07T17:01:21Z")

</div>

Hello,

I have tensor with values in `[-1, 0, 1, 2, 3, 4, 5]`  
I want to create mask for each value.

So far I did:

```auto
cats = [-1, 0, 1, 2, 3, 4, 5]]
masks = [labels == cat_id for cat_id in cats]
masks = torch.stack(masks, dim=1).int()

```

Do you know about faster and cleaner way to implement it?

Thanks in advance,  
Shon
