# Assertion \`t \>= 0 && t \< n\_classes\` failed error

**URL:** <https://discuss.pytorch.org/t/assertion-t-0-t-n-classes-failed-error/133794>\
**Category:** vision\
**Created:** [October 9, 2021, 7:46am UTC](https://discuss.pytorch.org/t/assertion-t-0-t-n-classes-failed-error/133794 "2021-10-09T07:46:00Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [October 9, 2021, 8:13pm UTC](https://discuss.pytorch.org/t/assertion-t-0-t-n-classes-failed-error/133794/6 "2021-10-09T20:13:40Z")

</div>

You are interpolating values using the bilinear approach and rounding afterwards, which might change the values. I’m not familiar with your use case, but as previously described, the expected target values are in `[0, nb_classes-1]` unless you use `ignore_index` for a specific index value.  
Your current code crashes, because the target values are not in this range.

---

_[View the full topic](https://discuss.pytorch.org/t/assertion-t-0-t-n-classes-failed-error/133794)._
