# Changing transformation applied to data during training

**URL:** <https://discuss.pytorch.org/t/changing-transformation-applied-to-data-during-training/15671>\
**Category:** Uncategorized\
**Created:** [March 29, 2018, 4:53pm UTC](https://discuss.pytorch.org/t/changing-transformation-applied-to-data-during-training/15671 "2018-03-29T16:53:58Z")\
**Posts on this page:** 1\
**Showing post:** 13

<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:** [December 17, 2021, 9:02pm UTC](https://discuss.pytorch.org/t/changing-transformation-applied-to-data-during-training/15671/13 "2021-12-17T21:02:09Z")

</div>

It depends on your workflow.  
The manipulation itself would work and `valset` would use the `new_transform` when `self.transform` is called. However, if you are wrapping `valset` into a `DataLoader` using multiple workers, you have to be careful when (and if) this change will be visible.  
When you start iterating the `DataLoader`, each worker will create a copy of the `Dataset` until the loop finishes. Changing the `valset` via `loader.dataset.transform = new_transform` would then be visible in the next epoch (or when you restart the `DataLoader` loop). Also, if you are using `persistent_workers=True`, the workers would never restart (and thus also never create a new copy of the dataset) and thus the change won’t be used.

---

_[View the full topic](https://discuss.pytorch.org/t/changing-transformation-applied-to-data-during-training/15671)._
