# Type of dataset in Trainer class

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftype-of-dataset-in-trainer-class%2F364%3E%5C
**Category:** Beginners\
**Created:** [July 17, 2020, 8:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftype-of-dataset-in-trainer-class%2F364 "2020-07-17T20:15:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![suyash21](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@suyash21](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsuyash21)%5C
**Post date:** [July 17, 2020, 8:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftype-of-dataset-in-trainer-class%2F364%2F1 "2020-07-17T20:15:48Z")

</div>

Hi, I was going through the documentation and got a confusion

trainer = Trainer(  
model=model, # the instantiated 🤗 Transformers model to be trained  
args=training\_args, # training arguments, defined above  
train\_dataset=train\_dataset, # training dataset  
eval\_dataset=test\_dataset # evaluation dataset  
)

I couldn’t understand what is the type of train\_dataset and how the target for loss calculation is selected.  
In Fine-tuning in native TensorFlow 2 also there is no target value. Am I missing something?  
`model.fit(train_dataset, epochs=2, steps_per_epoch=115)`

Thank you

---

<div class="post-metadata">

**Author:** ![mikaelsouza](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mikaelsouza](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmikaelsouza)%5C
**Post date:** [July 18, 2020, 4:50am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftype-of-dataset-in-trainer-class%2F364%2F2 "2020-07-18T04:50:00Z")

</div>

For more context, he/she is talking about this page: [https://huggingface.co/transformers/training.html](https://huggingface.co/transformers/training.html)

I also got confused by this bit of the documentation, but I think this code expects datasets like the ones provided by [Hugging Face’s NLP package](https://github.com/huggingface/nlp).

I think they are all based on [Pytorch’s Dataset Class](https://pytorch.org/docs/stable/data.html), but I could be mistaken.

Try to use one of the datasets provided by their NLP package and check if it works correctly.

Hope this helps! 🤗

---

<div class="post-metadata">

**Author:** ![valhalla](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/valhalla/32/4179_2.png) [@valhalla](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvalhalla)%5C
**Post date:** [July 18, 2020, 9:23am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftype-of-dataset-in-trainer-class%2F364%2F3 "2020-07-18T09:23:20Z")

</div>

Hi @suyash21 this [post](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-expected-by-trainer%2F148%2F2) has some explanation about the dataset expected by `Trainer`

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [July 20, 2020, 1:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftype-of-dataset-in-trainer-class%2F364%2F4 "2020-07-20T13:48:18Z")

</div>

`Trainer` is to be used with PyTorch, so in this case the `train_dataset` needs to be a PyTorch dataset. `TFTrainer` would expect a TF dataset. The [doc page](https://huggingface.co/transformers/main_classes/trainer.html) is a bit unclear (types are right in the signature but too short/wrong in the enumeration). I’ll send a fix to this later today.
