# Join / Append dataLoaders structures

**URL:** <https://discourse.julialang.org/t/join-append-dataloaders-structures/78873>\
**Category:** Machine Learning\
**Tags:** flux, data\_structures\
**Created:** [April 1, 2022, 2:37pm UTC](https://discourse.julialang.org/t/join-append-dataloaders-structures/78873 "2022-04-01T14:37:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lgmendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lgmendes/32/34577_2.png) [@lgmendes](https://discourse.julialang.org/u/lgmendes)\
**Post date:** [April 1, 2022, 2:37pm UTC](https://discourse.julialang.org/t/join-append-dataloaders-structures/78873/1 "2022-04-01T14:37:12Z")

</div>

Hi all,

How can I add / join /append two dataLoaders structures ?

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [April 2, 2022, 4:52am UTC](https://discourse.julialang.org/t/join-append-dataloaders-structures/78873/2 "2022-04-02T04:52:05Z")

</div>

I’m not aware of a way to do this, as the general advice is to join your data(sets) before creating a loader. Is there anything which would prevent you from doing that instead?

---

<div class="post-metadata">

**Author:** ![lgmendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lgmendes/32/34577_2.png) [@lgmendes](https://discourse.julialang.org/u/lgmendes)\
**Post date:** [April 2, 2022, 6:09am UTC](https://discourse.julialang.org/t/join-append-dataloaders-structures/78873/3 "2022-04-02T06:09:48Z")

</div>

Hi,

The objective is to “balance” the training dataset. I have an unbalanced dataset (80%- 20%) and I want to create a kind of upsample balanced mini-batches for training ensuring that in each mini-batches aren’t repeated data.  
If I upsample and after creating the (shuffle) data mini-batches the last condition is not ensured. Although I’m new to Julia, I have done a quick look at the source code of the dataloader, and seems that is easier to try modifying the FLUX training loop to have into account multiple dataloaders objects .

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [April 2, 2022, 4:55pm UTC](https://discourse.julialang.org/t/join-append-dataloaders-structures/78873/4 "2022-04-02T16:55:54Z")

</div>

I know the type of sampling you’re talking about, thanks for the clarification. Since you have a good grasp on what the training loop should look like, I’d recommend just writing a custom one. Flux’s default is very constrained and this is one of those cases where the intent of the balancing might be clearer if the iteration over multiple dataloaders is made explicit.
