jeffheaton / t81_558_deep_learning

T81-558: Keras - Applications of Deep Neural Networks @Washington University in St. Louis
https://sites.wustl.edu/jeffheaton/t81-558/
Other
5.71k stars 3.04k forks source link

Error in running t81_558_class_10_4_captioning.ipynb #29

Closed chinmaydas96 closed 4 years ago

chinmaydas96 commented 5 years ago

I am getting an error while training the model in Error in running t81_558_class_10_4_captioning.ipynb in this line

caption_model.fit_generator(generator, epochs=1, steps_per_epoch=steps, verbose=1)

It says

ValueError: could not broadcast input array from the shape (168,2048) into shape (168).

Not sure what I am doing wrong, everything works up to that line with the desired output.

jeffheaton commented 5 years ago

I will try running it through on the latest TensorFlow and see if I can reproduce.

blackwolf08 commented 4 years ago

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)]
jeffheaton commented 4 years ago

Thank you for the fix, it has been merged.