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

IndexError: index 1 is out of bounds for axis 0 with size 1 #15

Closed
tonyatml opened this issue Sep 7, 2017 · 5 comments
Closed

IndexError: index 1 is out of bounds for axis 0 with size 1 #15

tonyatml opened this issue Sep 7, 2017 · 5 comments

Comments

@tonyatml
Copy link

tonyatml commented Sep 7, 2017

IndexError Traceback (most recent call last)
in ()
29 {input_text: dyn_input, initial_state: prev_state})
30
---> 31 pred_word = pick_word(probabilities[dyn_seq_length-1], int_to_vocab)
32
33 gen_sentences.append(pred_word)

IndexError: index 1 is out of bounds for axis 0 with size 1

@YangWangGit
Copy link

Try to replace the line
pred_word = pick_word(probabilities[dyn_seq_length-1], int_to_vocab)
with
pred_word = pick_word(probabilities[0,dyn_seq_length-1,:], int_to_vocab)
This fix seems to work for me.

By the way, I finished the training, but did not get the same, reasonable quality of predicted text as zackthoutt demonstrated.

@zackthoutt
Copy link
Owner

@tonyatml, @YangWangGit are you using Tensorflow 1.0.0? @YangWangGit, the output of the network should not have a depth of three. That is likely why you are not getting good results.

Also keep in mind that training networks like this is tricky and involves a lot of tinkering. When I trained the network I ran several instances at once with different combinations of hyperparameters. I also downloaded all of the networks every half hour or so while they were training and tested how well they generated text.

I think that the model I actually ended up generating the text with used slightly different hyperparameters than what I have posted in this repo. I think my best one had a larger word embedding layer and a longer sequence length. Also note that I did not train the full number of epochs defined in the code. I stopped all of the models training well before reaching the max value. Training too much will either force your weights into a local minima or overfit, both of which lead to worse results.

@tonyatml
Copy link
Author

tonyatml commented Sep 11, 2017

@zackthoutt ,I am using version 1.3.0 installed via 'pip install' with GPU support. The python version is 2.7.12.

@zackthoutt
Copy link
Owner

You need to use Tensorflow 1.0.0. There are updates that will break the code in 1.3.0.

@vinothkumarsvv
Copy link

Traceback (most recent call last):
File "train.py", line 249, in
main()
File "train.py", line 246, in main
history = parallel_model.fit_generator(train_data_generator, epochs=FLAGS.max_epochs, steps_per_epoch=train_samples_count/FLAGS.batch_size, use_multiprocessing=False, callbacks=callbacks, verbose=1)
File "C:\Users\VINOTH KUMAR S\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Users\VINOTH KUMAR S\Anaconda3\lib\site-packages\keras\engine\training.py", line 1418, in fit_generator
initial_epoch=initial_epoch)
File "C:\Users\VINOTH KUMAR S\Anaconda3\lib\site-packages\keras\engine\training_generator.py", line 251, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
File "C:\Users\VINOTH KUMAR S\Anaconda3\lib\site-packages\keras\callbacks.py", line 79, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File "train.py", line 104, in on_epoch_end
input_image_summary = make_image_summary(((data[0][0][i] + 1) * 127.5).astype('uint8'))
IndexError: index 1 is out of bounds for axis 0 with size 1

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

4 participants