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

state = state[:, :, 0]*0.299 + state[:, :, 1]*0.587 + state[:, :, 2]*0.114 IndexError: index 2 is out of bounds for axis 2 with size 2 #8

Open
aspnetcs opened this issue Jan 13, 2019 · 5 comments

Comments

@aspnetcs
Copy link

when I run the following command
python train.py --data=configs/data.json --vocab=configs/vocab.json --training=configs/training.json --model=configs/model.json --output=results/full/
the result is
Loaded 76322 formulas from data/train.formulas.norm.txt
Bucketing the dataset...
Traceback (most recent call last):
File "train.py", line 61, in
main()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "train.py", line 36, in main
form_prepro=vocab.form_prepro)
File "/home/rootx/me/im2latex-master/model/utils/data_generator.py", line 76, in init
self._set_data_generator()
File "/home/rootx/me/im2latex-master/model/utils/data_generator.py", line 84, in _set_data_generator
self._data_generator = self.bucket(self._bucket_size)
File "/home/rootx/me/im2latex-master/model/utils/data_generator.py", line 104, in bucket
for idx, (img, formula, img_path, formula_id) in enumerate(self):
File "/home/rootx/me/im2latex-master/model/utils/data_generator.py", line 201, in iter
result, skip = self._process_instance(example)
File "/home/rootx/me/im2latex-master/model/utils/data_generator.py", line 173, in _process_instance
img = self._img_prepro(img)
File "/home/rootx/me/im2latex-master/model/utils/image.py", line 52, in greyscale
state = state[:, :, 0]*0.299 + state[:, :, 1]*0.587 + state[:, :, 2]*0.114
IndexError: index 2 is out of bounds for axis 2 with size 2
root@rootx-virtual-machine:/home/rootx/me/im2latex-master#
How to fix it?
Thanks a lot !

@jiancgao
Copy link

met the same error

@aspnetcs
Copy link
Author

aspnetcs commented May 1, 2020

Run under GPU environment, do not run under CPU environment

@aspnetcs
Copy link
Author

aspnetcs commented May 1, 2020 via email

@jiancgao
Copy link

Run under GPU environment, do not run under CPU environment

-- At 2020-05-01 01:22:07, "Jiancong Gao" [email protected] wrote: met the same error — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Hi, later I found it is a problem with the input data. I re-ran the program and it worked.
Also I modify your work a little bit to try adaptive attention and it worked pretty well. Brilliant code by you. Thanks!

@aspnetcs
Copy link
Author

aspnetcs commented May 15, 2020 via email

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

2 participants