Skip to content

How to Load Data with Python Generators for Multi-Modal and Multi-Task #1728

Answered by daraghimo
daraghimo asked this question in General
Discussion options

You must be logged in to vote

After searching and trying I reached the answer. I will put it here so it may help someone. I suggest adding it to the tutorial :).
here is an update to the generator displayed in the tutorial here If you have multiple inputs x and s:

def get_data_generator(n_batches, batch_size, n_features): # pass all variables used in generator
    def data_generator():
     # get x,s and y from your own loop
                    yield ((x,s), y)
    return data_generator
dataset_train = tf.data.Dataset.from_generator(
    get_data_generator(N_BATCHES, BATCH_SIZE, N_FEATURES), # pass training generator variables
    output_types=((tf.float32, tf.float32),tf.float32),   
    output_shapes= (([HEIGHT,WIDT…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by daraghimo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #1727 on May 17, 2022 05:15.