git clone https://github.com/google/seq2seq.git
cd seq2seq
# Install package and dependencies
pip install -e .
安装后要进行测试:
python -m unittest seq2seq.test.pipeline_test
我测试后出现:
-
ImportError: cannot import name contrib
解决方法:
修改 : seq2seq/seq2seq/contrib/seq2seq/helper.py
#from tensorflow.contrib.distributions.python.ops import bernoulli
#from tensorflow.contrib.distributions.python.ops import categorical
try:
from tensorflow.python.ops.distributions import bernoulli
from tensorflow.python.ops.distributions import categorical
except:
from tensorflow.contrib.distributions.python.ops import bernoulli
from tensorflow.contrib.distributions.python.ops import categorical
2. AttributeError: 'module' object has no attribute '_FlagValues'
修改 seq2seq/test/pipeline_test.py 这个文件
sudo vim seq2seq/test/pipeline_test.py
修改 def _clear_flags() 这个方法
改为下面这种:
def _clear_flags(): """Resets Tensorflow's FLAG values""" #pylint: disable=W0212 for flag_key in dir(tf.app.flags.FLAGS): delattr(tf.app.flags.FLAGS, flag_key) #tf.app.flags.FLAGS = tf.app.flags._FlagValues() tf.app.flags._global_parser = argparse.ArgumentParser()
在python3.6 上边的安装如下:
on mac & python3.6
pip3 install git+https://github.com/datalogai/recurrentshop.git
pip3 install git+https://github.com/farizrahman4u/seq2seq.git