Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow translate.py import error: No module named translate

I'm trying to run Tensorflow's translate.py from a python console rather than through bazel -build, but I get an error at these two lines:

from tensorflow.models.rnn.translate import data_utils
from tensorflow.models.rnn.translate import seq2seq_model

ImportError: No module named translate

I've checked the folder to see that the "init.py" file is there, but python seems to think there is no such module as translate. How can i fix this?

like image 902
user4383691 Avatar asked Sep 27 '22 03:09

user4383691


2 Answers

The best way to do this is to navigate to folder containing the translate module and running it. You can also download the translate module to any other place and run it. However, don't forget to change the above lines to:

from translate import data_utils
from translate import seq2seq_model
like image 91
Anurag Ranjan Avatar answered Sep 29 '22 21:09

Anurag Ranjan


I resolved this issue by removing all the from tensorflow.models.rnn.translate statements, leaving just

import data_utils
import seq2seq_model

in translate.py and

import data_utils

in seq2seq_model.py.

like image 30
Tein van der Lugt Avatar answered Sep 29 '22 22:09

Tein van der Lugt