ValueError Traceback (most recent call last)
in ()
3 for i in tqdm(range(EPOCHS*2)):
4 generator = data_generator(train_descriptions, encoding_train, wordtoidx, max_length, number_pics_per_bath)
----> 5 caption_model.fit_generator(generator, epochs=1, steps_per_epoch=steps, verbose=1)
6
7 caption_model.optimizer.lr = 1e-4
2 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training_generator.py in _get_next_batch(generator, mode)
370 raise ValueError('Output of generator should be '
371 'a tuple (x, y, sample_weight) '
--> 372 'or (x, y). Found: ' + str(generator_output))
373
374 if len(generator_output) < 1 or len(generator_output) > 3:
Problem
When training the NN it throws this error
ValueError Traceback (most recent call last) in () 3 for i in tqdm(range(EPOCHS*2)): 4 generator = data_generator(train_descriptions, encoding_train, wordtoidx, max_length, number_pics_per_bath) ----> 5 caption_model.fit_generator(generator, epochs=1, steps_per_epoch=steps, verbose=1) 6 7 caption_model.optimizer.lr = 1e-4
2 frames /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training_generator.py in _get_next_batch(generator, mode) 370 raise ValueError('Output of generator should be ' 371 'a tuple (x, y, sample_weight) ' --> 372 'or (x, y). Found: ' + str(generator_output)) 373 374 if len(generator_output) < 1 or len(generator_output) > 3:
ValueError: Output of generator should be a tuple (x, y, sample_weight) or (x, y). Found: [[array([[0.1227757 , 0.33294907, 0.7527157 , ..., 0.21939711, 0.30216414, 0.40283215], [0.1227757 , 0.33294907, 0.7527157 , ..., 0.21939711, 0.30216414, 0.40283215], [0.1227757 , 0.33294907, 0.7527157 , ..., 0.21939711, 0.30216414, 0.40283215], ..., [0.37351927, 0.24596639, 0.96352935, ..., 1.1459347 , 0.26539996, 0.01983135], [0.37351927, 0.24596639, 0.96352935, ..., 1.1459347 , 0.26539996, 0.01983135], [0.37351927, 0.24596639, 0.96352935, ..., 1.1459347 , 0.26539996, 0.01983135]], dtype=float32), array([[ 0, 0, 0, ..., 0, 0, 1], [ 0, 0, 0, ..., 0, 1, 2], [ 0, 0, 0, ..., 1, 2, 3], ..., [ 0, 0, 0, ..., 66, 68, 3], [ 0, 0, 0, ..., 68, 3, 21], [ 0, 0, 0, ..., 3, 21, 61]], dtype=int32)], array([[0., 0., 1., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], dtype=float32)]
Solution
Tensor flow required a tuple to be returned