Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenating Tasks? #513

Closed
gahdritz opened this issue Mar 28, 2023 · 2 comments
Closed

Concatenating Tasks? #513

gahdritz opened this issue Mar 28, 2023 · 2 comments

Comments

@gahdritz
Copy link

Is there a way to concatenate multiple Tasks? Mixtures sample from component Tasks until one of them runs out of examples. Is there a variant that uses all of the examples from both Tasks in each epoch?

@gahdritz gahdritz changed the title Concatenate tasks Concatenating Tasks? Mar 28, 2023
@StephennFernandes
Copy link

working on something similar, please let me know if you find something

@adarob
Copy link
Member

adarob commented Mar 31, 2023

Do you just want to use all of the examples or do you want one task to come first followed by another? To do the first, set the following argument on the Mixture constructor:

sample_fn = functools.partial(tf.data.Dataset.sample_from_datasets, stop_on_empty_dataset=False)

To do the second, you could probably do the following:

concat_fn = lambda a, b: a.concatenate(b)
...
sample_fn = lambda datasets, _, _: functools.reduce(concat_fn, datasets)

@adarob adarob closed this as completed Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants