AI_Composer
AI_Composer copied to clipboard
ImportError: This module is deprecated. Use tf.nn.rnn_cell instead.
james@:~/ai/AI_Composer$ python main.py
Traceback (most recent call last):
File "main.py", line 4, in
(Using TensorFlow binary: https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl)
I looked in /usr/local/lib/python2.7/dist-packages/tensorflow/models/rnn/rnn_cell.py and sure enough it just spits out that deprecation message.
The relevant line in /home/james/ai/AI_Composer/model.py:
from tensorflow.models.rnn import rnn_cell
I'm too noob to all of this to figure out how to put tf.nn.rnn_cell in there instead. I tried this:
james@MUSSLI:~/ai/AI_Composer$ python main.py
Traceback (most recent call last):
File "main.py", line 4, in <module>
import rnn
File "/home/james/ai/AI_Composer/rnn.py", line 16, in <module>
from model import Model, NottinghamModel
File "/home/james/ai/AI_Composer/model.py", line 5
from tensorflow.models.rnn import tf.nn.rnn_cell
^
SyntaxError: invalid syntax
I tried to figure out where "tf" and "nn" are if they go in the import string somehow...
james@MUSSLI:/usr/local/lib/python2.7/dist-packages/tensorflow$ find . -name tf
james@MUSSLI:/usr/local/lib/python2.7/dist-packages/tensorflow$ find . -name nn
james@MUSSLI:/usr/local/lib/python2.7/dist-packages/tensorflow$ find . -name rnn_cell.py
./models/rnn/rnn_cell.py
./python/ops/rnn_cell.py
./contrib/rnn/python/ops/rnn_cell.py
tf and nn are not there?
Can you please specify the version of TensorFlow or solve the 0.9 issue? (Or both?)
Hey @jamesalton thanks for pointing this out. If you made a fix, would you be willing to make a PR? I'd merge it immediately, amount of code i have to maintain is exploding with each video lol
I am currently experiencing the same issue. I'm using Ubuntu 16.04 Desktop.
ubuntu@ubuntu-VirtualBox:~/AI_Composer$ python rnn_sample.py --config_file new_config_file.config
Traceback (most recent call last):
File "rnn_sample.py", line 12, in <module>
from model import Model, NottinghamModel
File "/home/ubuntu/AI_Composer/model.py", line 5, in <module>
from tensorflow.models.rnn import rnn_cell
File "/usr/local/lib/python2.7/dist-packages/tensorflow/models/rnn/rnn_cell.py", line 21, in <module>
raise ImportError("This module is deprecated. Use tf.nn.rnn_cell instead.")
ImportError: This module is deprecated. Use tf.nn.rnn_cell instead.
ubuntu@ubuntu-VirtualBox:~/AI_Composer$
Following the Tensorflow install guide on this page: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md, but with the modified download link:
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
sudo pip install --upgrade $TF_BINARY_URL
Trying to run the code results in an error:
ubuntu@ubuntu-VirtualBox:~/AI_Composer$ python rnn_sample.py --config_file new_config_file.config
Traceback (most recent call last):
File "rnn_sample.py", line 13, in <module>
from rnn import DefaultConfig
File "/home/ubuntu/AI_Composer/rnn.py", line 12, in <module>
import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot
ubuntu@ubuntu-VirtualBox:~/AI_Composer$
So I install the following missing modules:
$ pip install matplotlib
$ sudo apt-get install python-tk
Which got me to:
ubuntu@ubuntu-VirtualBox:~/AI_Composer$ python rnn_sample.py --config_file new_config_file.config
Traceback (most recent call last):
File "rnn_sample.py", line 29, in <module>
with open(args.config_file, 'r') as f:
IOError: [Errno 2] No such file or directory: 'new_config_file.config'
ubuntu@ubuntu-VirtualBox:~/AI_Composer$
ubuntu@ubuntu-VirtualBox:~/AI_Composer$ sudo python main.py
Parsing train...
Parsing test...
Parsing valid...
After some time:
Model created!
And now it seems to work!
It seems it froze?
ubuntu@ubuntu-VirtualBox:~/AI_Composer$ sudo python main.pyParsing train...
Parsing test...
Parsing valid...
{'A': 24752,
'A#': 86,
'AM': 44184,
'Am': 28532,
'B': 2652,
'BM': 176,
'BbM': 6300,
'Bm': 12650,
'C': 2820,
'C#': 82,
'C#m': 278,
'CM': 40764,
'Cm': 1912,
'D': 21362,
'D#': 100,
'DM': 109802,
'Dm': 5622,
'E': 11728,
'EM': 4218,
'EbM': 1428,
'Em': 32768,
'F': 734,
'F#': 635,
'F#M': 248,
'F#m': 2332,
'FM': 11074,
'Fm': 80,
'G': 5154,
'GM': 123400,
'Gm': 6540,
'NONE': 11916}
Number of chords: 31
Max Sequence length: 3588
Avg Sequence length: 516.057171515
Num Sequences: 997
Combining train
Combining test
Combining valid
Model created!
Finished loading data, input dim: 66
1 runs detected
Num Layers: 2, Hidden Size: 200, Melody Coeff: 0.5, Dropout Prob: 0.5, Input Dropout Prob: 0.8, Cell Type: lstm, Time Batch Len: 128, Learning Rate: 0.005, Decay: 0.9
It seems to be working, but does it constantly save to the model file? Or only after a certain period of time?
Epoch: 1, Train Loss: 2.78163759443, Time Per Epoch: 480.647743225
Valid Loss: 2.88543242747
@ProGamerGov awesome, can you make a PR with your changes? I'm getting a lot of questions about this and it seems you've found a fix
it constantly saves to the model file, gets betters with time
I have created PR with the changes. It's not the prettiest installation guide, but it resolves the Tensorflow version related errors people have been having.
@ProGamerGov you're my hero thank you
can't generate music
`Traceback` (most recent call last):
File "rnn_sample.py", line 58, in <module>
saver.restore(session, model_path)
File "/home/derek/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1088, in restore
raise ValueError("Restore called with invalid save path %s" % save_path)
ValueError: Restore called with invalid save path F5PTV3HFEGJA.model
I found that if I change the two lines line model.py from:
from tensorflow.models.rnn import rnn_cell from tensorflow.models.rnn import rnn, seq2seq
to: from tensorflow.python.ops import rnn_cell from tensorflow.python.ops import rnn, seq2seq
It seems to work fine (although so far I've only done training), and I don't have to revert to an earlier version of Tensorflow.
@llSourcell I can make a pull request if you're interested.
It seems I spoke too soon on this issue; my Tensorflow was not on the latest version, and it there are numerous differences in the Tensorflow 1.0 API that are causing issues.