# I'm getting "nan" value for loss, while following a tutorial from the documentatin

**URL:** <https://discuss.huggingface.co/t/im-getting-nan-value-for-loss-while-following-a-tutorial-from-the-documentatin/1530>\
**Category:** 🤗Transformers\
**Created:** [October 14, 2020, 12:02pm UTC](https://discuss.huggingface.co/t/im-getting-nan-value-for-loss-while-following-a-tutorial-from-the-documentatin/1530 "2020-10-14T12:02:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunny](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sunny](https://discuss.huggingface.co/u/sunny)\
**Post date:** [October 14, 2020, 12:02pm UTC](https://discuss.huggingface.co/t/im-getting-nan-value-for-loss-while-following-a-tutorial-from-the-documentatin/1530/1 "2020-10-14T12:02:03Z")

</div>

Hi,

I’m following the “Fine-tuning with Custom Dataset” tutorial for Question Answering on the SQuaD dataset tutorial: [available here](https://huggingface.co/transformers/custom_datasets.html#question-answering-with-squad-2-0). I’ve copy pasted all the code shown in the tutorial step by step. However, when my model starts training, I don’t get the expected metric values for loss as I normally would, instead I get “nan”. Here is the output when I run the  
`model.fit(train_dataset.shuffle(1000).batch(16), epochs=3, batch_size=16)`

Epoch 1/3  
5427/5427 [==============================] - 4604s 848ms/step - loss: nan - output\_1\_loss: nan - output\_2\_loss: nan  
Epoch 2/3  
365/5427 [=\>…] - ETA: 1:11:28 - loss: nan - output\_1\_loss: nan - output\_2\_loss: nan

I don’t know what is wrong, and I don’t think this output is what is supposed to be.

Would appreciate any help with this regard.  
Thank you.
