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

neural-machine-translation - nmt ZeroDivisionError: integer division or modulo by zero #10

Open
abdoelsayed2016 opened this issue Feb 16, 2020 · 1 comment

Comments

@abdoelsayed2016
Copy link

abdoelsayed2016 commented Feb 16, 2020

Traceback (most recent call last):

File "", line 1, in
runfile('D:/nlp-tutorial/neural-machine-translation/nmt/train.py', wdir='D:/nlp-tutorial/neural-machine-translation/nmt')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/nlp-tutorial/neural-machine-translation/nmt/train.py", line 254, in
trainiters(pairs, encoder, decoder, n_iters)

File "D:/nlp-tutorial/neural-machine-translation/nmt/train.py", line 184, in trainiters
train_pairs += [random.choice(train_pairs) for i in range(n_iters%len(train_pairs))]

ZeroDivisionError: integer division or modulo by zero

@abdoelsayed2016
Copy link
Author

I got a solution for that
3 line in your code must change from
train_pairs *= n_iters//len(train_pairs)
train_pairs += [random.choice(train_pairs) for i in range(n_iters%len(train_pairs))]
train_pairs = [tensorsFromPair(pair) for pair in train_pairs]
to
train_pairs = [tensorsFromPair(random.choice(train_pairs))
for i in range(n_iters)]

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

1 participant