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

Question #2

Open
enssaf opened this issue Aug 26, 2019 · 0 comments
Open

Question #2

enssaf opened this issue Aug 26, 2019 · 0 comments

Comments

@enssaf
Copy link

enssaf commented Aug 26, 2019

please,, help me, how could I combine 3 numerical vectors with image features vectors using a generator, what is wrong in this code

def combined_generators(image_generator, x_data, y_data, z_data, batch_size):
x_gen = cycle(batch(x_data, batch_size))
y_gen = cycle(batch(y_data, batch_size))
z_gen = cycle(batch(z_data, batch_size))

while True:
    nextImage = next(image_generator)
    
    nextx = next(x_gen)
    assert len(nextImage[0]) == len(nextx)

    nexty = next(y_gen)
    assert len(nextImage[0]) == len(nexty)

    nextz = next(z_gen)
    assert len(nextImage[0]) == len(nextz)
    
    yield [nextImage[0], nextx, nexty, nextz], nextImage[1]

def batch(iterable, n=1):
l = len(iterable)
for ndx in range(0, l, n):
yield iterable[ndx:min(ndx + n, l)]

train_gen_wrapper = combined_generators(train_batches, df['x'], df['y'], df['z'], 16)
val_gen_wrapper = combined_generators(valid_batches, dft['x'], dft['y'], dft['z'], 16)

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

1 participant