hunkim / word-rnn-tensorflow

Multi-layer Recurrent Neural Networks (LSTM, RNN) for word-level language models in Python using TensorFlow.
MIT License
1.3k stars 494 forks source link

example not working #74

Open sp00ck opened 6 years ago

sp00ck commented 6 years ago
 python train.py
Traceback (most recent call last):
  File "train.py", line 11, in <module>
    from model import Model
  File "/home/user/word-rnn-tensorflow/model.py", line 3, in <module>
    from tensorflow.contrib import legacy_seq2seq
ImportError: cannot import name legacy_seq2seq

i have tensorflow ok

Wrench-wench commented 4 years ago

I've had a similar issue with train.py calling tensorflow.contrib

Solved by running python -m pip install tensorflow==1.14 from inside the python venv I was using.

Ubuntu 18.04 LTS Tensorflow 1.14 Python 3.6.9

Hope this helps with your issue.

sp00ck commented 4 years ago
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement tensorflow==1.14 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0)
ERROR: No matching distribution found for tensorflow==1.14

$uname -a Linux 5.7.12-200.fc32.x86_64 #1 SMP Sat Aug 1 16:13:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Wrench-wench commented 4 years ago

Interesting. The only way I could replicate the error message is by misspelling the package name, but by your reply I can see it was spelt correctly.

I installed a fresh copy of Ubuntu 18.04 on a machine and setup Word-RNN-Tensorflow. Here are all the commands I used to set it up in a Python venv, hopefully one of these are your fix.

# Update the OS software and grab some Python packages. 
sudo apt update && sudo apt upgrade -y
sudo apt install python3-dev python3-pip python3-venv git

# Make a directory and start a Python virtual environment in it
mkdir projectfolder 
python3 -m venv --system-site-packages projectfolder/
source projectfolder/bin/activate

# Move in to the folder, get the needed Python modules and clone the git 
cd projectfolder/
pip install --upgrade pip setuptools tensorflow==1.14
git clone https://github.com/hunkim/word-rnn-tensorflow.git

# Start Word-RNN using the provided example set
cd word-rnn-tensorflow
python train.py

Good luck!

EDIT: Forgot about markdown, changed formatting.