seq2seq安装问题

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 .

安装后要进行测试:

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

  1. 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 博客 ,全文地址请点击:https://blog.csdn.net/yangzm/article/details/82626798?utm_source=copy

你可能感兴趣的:(seq2seq安装问题)