# Error when training SCVI on reference data

**URL:** <https://discourse.scverse.org/t/error-when-training-scvi-on-reference-data/519>\
**Category:** scvi-tools\
**Tags:** scvi\
**Created:** [June 3, 2022, 11:09pm UTC](https://discourse.scverse.org/t/error-when-training-scvi-on-reference-data/519 "2022-06-03T23:09:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TemiLeke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/temileke/32/272_2.png) [@TemiLeke](https://discourse.scverse.org/u/TemiLeke)\
**Post date:** [June 3, 2022, 11:09pm UTC](https://discourse.scverse.org/t/error-when-training-scvi-on-reference-data/519/1 "2022-06-03T23:09:43Z")

</div>

When attempting to train a SCVI model for reference mapping, I get the following error

`Expected parameter loc (Tensor of shape (128, 10)) of distribution Normal(loc: torch.Size([128, 10]), scale: torch.Size([128, 10])) to satisfy the constraint Real(), but found invalid values:`

---

<div class="post-metadata">

**Author:** ![TemiLeke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/temileke/32/272_2.png) [@TemiLeke](https://discourse.scverse.org/u/TemiLeke)\
**Post date:** [June 3, 2022, 11:10pm UTC](https://discourse.scverse.org/t/error-when-training-scvi-on-reference-data/519/2 "2022-06-03T23:10:37Z")

</div>

Here is the line of code ` scvi_model = scvi.model.SCVI(adata_train, **scvi_params)`

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [June 4, 2022, 9:13am UTC](https://discourse.scverse.org/t/error-when-training-scvi-on-reference-data/519/3 "2022-06-04T09:13:49Z")

</div>

Can you tell us more about your data and show us the code for setting up your anndata?

---

<div class="post-metadata">

**Author:** ![TemiLeke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/temileke/32/272_2.png) [@TemiLeke](https://discourse.scverse.org/u/TemiLeke)\
**Post date:** [June 4, 2022, 2:17pm UTC](https://discourse.scverse.org/t/error-when-training-scvi-on-reference-data/519/4 "2022-06-04T14:17:12Z")

</div>

![Screen Shot 2022-06-04 at 10.16.30 AM](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/9a430410189c27f04eca189150bc8778f2579958.png)

As shown in the screenshot, the training data has negative values because it is batch corrected data. So i suspect this error is a result of that. Is there a way to make this work? some normalization perhaps?

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [June 4, 2022, 3:04pm UTC](https://discourse.scverse.org/t/error-when-training-scvi-on-reference-data/519/5 "2022-06-04T15:04:30Z")

</div>

what is inside `adata.layers['counts']`? `SCVI` does indeed require count valued data
