elliottd / GroundedTranslation

Multilingual image description
https://staff.fnwi.uva.nl/d.elliott/GroundedTranslation/
BSD 3-Clause "New" or "Revised" License
46 stars 25 forks source link

IndexError during training #21

Open walidar opened 8 years ago

walidar commented 8 years ago

I got the following error, any help what is the problem? I am using the latest code ..

INFO:Callbacks:Initialising with the first 1 gold words (incl BOS) Traceback (most recent call last): File "/lium/buster1/aransa/workspace/GroundedTranslation/train.py", line 282, in model.train_model() File "/lium/buster1/aransa/workspace/GroundedTranslation/train.py", line 134, in train_model shuffle=True) File "/lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/keras/models.py", line 402, in fit sample_weight=sample_weight) File "/lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/keras/engine/training.py", line 1036, in fit callback_metrics=callback_metrics) File "/lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/keras/engine/training.py", line 795, in _fit_loop callbacks.on_epoch_end(epoch, epoch_logs) File "/lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/keras/callbacks.py", line 39, in on_epoch_end callback.on_epoch_end(epoch, logs) File "/lium/buster1/aransa/workspace/GroundedTranslation/Callbacks.py", line 97, in on_epoch_end self.generate_sentences(path) File "/lium/buster1/aransa/workspace/GroundedTranslation/Callbacks.py", line 373, in generate_sentences arrays[0][i, t, next_word_indices[i]] = 1. IndexError: index 42 is out of bounds for axis 1 with size 42

elliottd commented 8 years ago

@walidar could you say more about the packages on your system (Theano, Keras, CUDA, etc.) and which dataset you're trying to run this on?

walidar commented 8 years ago

@elliottd I am using flickr30k dataset I am using CUDA 6.5 and Python 2.7 with the following packages:

cython 0.24 h5py 2.6.0 keras 1.0.1 numpy 1.11.0 openssl 1.0.2g 0
pip 8.1.1 py27_1
python 2.7.11 0
pyyaml 3.11 readline 6.2 2
scipy 0.17.0 setuptools 20.7.0 py27_0
six 1.10.0 sqlite 3.9.2 0
theano 0.8.2 tk 8.5.18 0
wheel 0.29.0 py27_0
zlib 1.2.8 0

elliottd commented 8 years ago

@walidar I think I see the problem. The master branch of the code only supports Keras 0.1.3 and you are using Keras 1.0.1. A lot has changed in Keras since we wrote the original code.

The code in the experimental_datagen branch supports Keras 0.3.3 but it is still experimental.

If you use pip install -r requirements.txt to install the dependencies then you should be able to use the code.

walidar commented 8 years ago

Thank you @elliottd for your fast reply ..

I installed the correct versions from requirments but I still got the same error: INFO:Callbacks:Initialising with the first 1 gold words (incl BOS) Traceback (most recent call last): File "/lium/buster1/aransa/workspace/GroundedTranslation/train.py", line 282, in model.train_model() File "/lium/buster1/aransa/workspace/GroundedTranslation/train.py", line 134, in train_model shuffle=True) File "/lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/keras/models.py", line 490, in fit shuffle=shuffle, metrics=metrics) File "/lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/keras/models.py", line 231, in _fit callbacks.on_epoch_end(epoch, epoch_logs) File "/lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/keras/callbacks.py", line 36, in on_epoch_end callback.on_epoch_end(epoch, logs) File "/lium/buster1/aransa/workspace/GroundedTranslation/Callbacks.py", line 97, in on_epoch_end self.generate_sentences(path) File "/lium/buster1/aransa/workspace/GroundedTranslation/Callbacks.py", line 373, in generate_sentences arrays[0][i, t, next_word_indices[i]] = 1. IndexError: index 42 is out of bounds for axis 1 with size 42 End of 1. training the English model @ 2016-04-25 18:55:22.514374

before that there is a warning: INFO:models:... visual: adding image features as input features /lium/buster1/aransa/miniconda2/envs/mlm_env/lib/python2.7/site-packages/theano/gof/cmodule.py:293: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility rval = import(module_name, {}, {}, [module_name]) INFO:data_generator:Generating training data batch

elliottd commented 8 years ago

@walidar hmm, now I am confused.

The error message is telling you that generate_sentences() in Callbacks.py is trying to generate descriptions for longer than the maximum --generation_timesteps in the datastructure (axis 1).

Could you share the command line arguments you're using to run train.py?