seq2seq icon indicating copy to clipboard operation
seq2seq copied to clipboard

What's wrong with bernoulli?

Open me2beats opened this issue 7 years ago • 5 comments

ERROR: seq2seq (unittest.loader._FailedTest)

ImportError: Failed to import test module: seq2seq Traceback (most recent call last): File "/usr/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName module = import(module_name) File "/content/seq2seq/seq2seq/init.py", line 26, in from seq2seq import decoders File "/content/seq2seq/seq2seq/decoders/init.py", line 20, in from seq2seq.decoders.attention_decoder import * File "/content/seq2seq/seq2seq/decoders/attention_decoder.py", line 27, in from seq2seq.contrib.seq2seq.helper import CustomHelper File "/content/seq2seq/seq2seq/contrib/seq2seq/helper.py", line 35, in from tensorflow.contrib.distributions.python.ops import bernoulli ImportError: cannot import name 'bernoulli'


Ran 1 test in 0.000s

FAILED (errors=1)

I saw similar issue here but I didn't find a good solution. I use Google Colab. Everything went ok till I ran pipeline_test

Python3, gpu

me2beats avatar Oct 28 '18 15:10 me2beats

same problem occurred...

cauivy avatar Nov 06 '18 09:11 cauivy

Reproduced on macOS 10.14 (18A391) with Python 3.7.0 installed via Homebrew, following the instructions at https://www.tensorflow.org/install/pip — looks like I need to downgrade to 3.6?

(venv) $ python -m unittest seq2seq.test.pipeline_test
/Users/clarity/venv/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.6 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.7
  return f(*args, **kwds)
E
======================================================================
ERROR: seq2seq (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: seq2seq
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/Users/clarity/Downloads/seq2seq/seq2seq/__init__.py", line 26, in <module>
    from seq2seq import decoders
  File "/Users/clarity/Downloads/seq2seq/seq2seq/decoders/__init__.py", line 20, in <module>
    from seq2seq.decoders.attention_decoder import *
  File "/Users/clarity/Downloads/seq2seq/seq2seq/decoders/attention_decoder.py", line 27, in <module>
    from seq2seq.contrib.seq2seq.helper import CustomHelper
  File "/Users/clarity/Downloads/seq2seq/seq2seq/contrib/seq2seq/helper.py", line 35, in <module>
    from tensorflow.contrib.distributions.python.ops import bernoulli
ImportError: cannot import name 'bernoulli' from 'tensorflow.contrib.distributions.python.ops' (/Users/clarity/venv/lib/python3.7/site-packages/tensorflow/contrib/distributions/python/ops/__init__.py)


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
(venv) $ uname -a
Darwin [redacted] 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
(venv) $ pip list
Package             Version Location
------------------- ------- --------------------------------
absl-py             0.6.1
appnope             0.1.0
astor               0.7.1
autopep8            1.3.5
backcall            0.1.0
bleach              2.1.4
cycler              0.10.0
decorator           4.3.0
defusedxml          0.5.0
entrypoints         0.2.3
gast                0.2.0
grpcio              1.16.0
h5py                2.8.0
html5lib            1.0.1
ipykernel           5.0.0
ipython             6.5.0
ipython-genutils    0.2.0
ipywidgets          7.4.2
jedi                0.12.1
Jinja2              2.10
jsonschema          2.6.0
jupyter             1.0.0
jupyter-client      5.2.3
jupyter-console     5.2.0
jupyter-core        4.4.0
Keras-Applications  1.0.6
Keras-Preprocessing 1.0.5
kiwisolver          1.0.1
Markdown            3.0.1
MarkupSafe          1.0
matplotlib          2.2.3
mistune             0.8.3
nbconvert           5.4.0
nbformat            4.4.0
nltk                3.3
notebook            5.7.0
numpy               1.15.1
pandas              0.23.4
pandocfilters       1.4.2
parso               0.3.1
pexpect             4.6.0
pickleshare         0.7.4
Pillow              5.3.0
pip                 18.1
prometheus-client   0.3.1
prompt-toolkit      1.0.15
protobuf            3.6.1
ptyprocess          0.6.0
pycodestyle         2.4.0
Pygments            2.2.0
pyparsing           2.2.0
pyrouge             0.1.3
python-dateutil     2.7.3
pytz                2018.5
PyYAML              3.13
pyzmq               17.1.2
qtconsole           4.4.1
scikit-learn        0.19.2
scipy               1.1.0
Send2Trash          1.5.0
seq2seq             0.1     /Users/clarity/Downloads/seq2seq
setuptools          39.1.0
simplegeneric       0.8.1
six                 1.11.0
tensorboard         1.11.0
tensorflow          1.11.0
termcolor           1.1.0
terminado           0.8.1
testpath            0.3.1
torch               0.4.1
torchvision         0.2.1
tornado             5.1.1
traitlets           4.3.2
virtualenv          16.1.0
wcwidth             0.1.7
webencodings        0.5.1
Werkzeug            0.14.1
wheel               0.32.2
widgetsnbextension  3.4.2
(venv) $

kk4ead avatar Nov 06 '18 18:11 kk4ead

My version of python was 3.6.5 and I installed tensorflow whose version was 1.0. Then I ran the test and no problem appeared.

qazwsx74269 avatar Dec 15 '18 09:12 qazwsx74269

I have found a solution in #285 It work for me.

Dr-Corgi avatar Jan 15 '19 02:01 Dr-Corgi

It's a tensorflow version problem. It was built on tensorflow==1.0.0. To solve it, go to the file seq2seq/contrib/seq2seq/helper.py change

from tensorflow.contrib.distributions.python.ops import bernoulli
from tensorflow.contrib.distributions.python.ops import categorical
sample_id_sampler = categorical.Categorical(logits=outputs)
sampler = bernoulli.Bernoulli(probs=self._sampling_probability)

to

from tensorflow.contrib.distributions import Bernoulli
from tensorflow.contrib.distributions import Categorical
sample_id_sampler = Categorical(logits=outputs)
sampler = Bernoulli(probs=self._sampling_probability)

reference: https://medium.com/@aloofness54/fix-google-seq2seq-installation-errors-4a1155b13f73

TangHan54 avatar Apr 03 '19 13:04 TangHan54