https://blog.csdn.net/yangzm/article/details/82626798
git clone https://github.com/google/seq2seq.git
cd seq2seq
Install package and dependencies
pip install -e .
安裝后要進(jìn)行測試:
python -m unittest seq2seq.test.pipeline_test
我測試后出現(xiàn):
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
- 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()
本文來自 yangzmpang1 的CSDN 博客 ,全文地址請點(diǎn)擊:https://blog.csdn.net/yangzm/article/details/82626798?utm_source=copy