# Set batch instead of full train dataset on Trainer

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fset-batch-instead-of-full-train-dataset-on-trainer%2F51903%3E%5C
**Category:** 🤗Transformers\
**Created:** [August 24, 2023, 2:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fset-batch-instead-of-full-train-dataset-on-trainer%2F51903 "2023-08-24T02:47:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![angeljcarrillo](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@angeljcarrillo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fangeljcarrillo)%5C
**Post date:** [August 24, 2023, 2:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fset-batch-instead-of-full-train-dataset-on-trainer%2F51903%2F1 "2023-08-24T02:47:12Z")

</div>

```auto
trainer = Trainer(
    model=model,
    data_collator=data_collator,
    args=training_args,
    compute_metrics=compute_metrics,
    train_dataset=common_voice_train,
    eval_dataset=common_voice_test,
    tokenizer=processor.feature_extractor,
)

```

I would like to set batch in train\_dataset, instead of the full set, because at the beginning take so much time to preprocess and load all the dataset when it could be done per batch inside the Train fuction, any help on how to do it?, also the same for the

```auto
 for param in model.base_model.parameters():
    param.requires_grad = False

```

I would like to set to true after n number of steps, but I cant figure out how to trigger that action from the Trainer

---

<div class="post-metadata">

**Author:** ![JRJ42](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@JRJ42](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJRJ42)%5C
**Post date:** [March 11, 2024, 1:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fset-batch-instead-of-full-train-dataset-on-trainer%2F51903%2F2 "2024-03-11T13:12:34Z")

</div>

Did you find out how to load the data batch by batch?
