AI_Composer icon indicating copy to clipboard operation
AI_Composer copied to clipboard

Fixing: 'This module is deprecated'

Open taleslimaf opened this issue 7 years ago • 11 comments

Hello Siraj,

I fixed the model.py for the 0.10.0 version of tensorflow.

taleslimaf avatar Feb 24 '17 19:02 taleslimaf

@Atles The rnn_cell, rnn, etc. can now be imported correctly with your fix, but I'm getting an error in the code about the zero_state. It seems to have returned a tuple instead of a tensor. Do you have any idea of how to fix that? Thanks.

Traceback (most recent call last):
  File "main.py", line 17, in <module>
    rnn.train_model()
  File "/Users/xslittlegrass/Downloads/AI_Composer/rnn.py", line 142, in train_model
    data["train"]["data"], training=True, testing=False)
  File "/Users/xslittlegrass/Downloads/AI_Composer/util.py", line 190, in run_epoch
    state = model.get_cell_zero_state(session, batch_size)
  File "/Users/xslittlegrass/Downloads/AI_Composer/model.py", line 98, in get_cell_zero_state
    return self.cell.zero_state(batch_size, tf.float32).eval(session=session)
AttributeError: 'tuple' object has no attribute 'eval'

xslittlegrass avatar Feb 28 '17 23:02 xslittlegrass

Hi @xslittlegrass, I have submit the first version with an error.

I have put this in the code: cell = cell_class(hidden_size, num_units=input_size)

But must be this: cell = cell_class(hidden_size, input_size = input_size)

Check if this is the problem.

taleslimaf avatar Feb 28 '17 23:02 taleslimaf

@Atles I pulled directly from your repo at https://github.com/Atles/AI_Composer. In that repo, the line you mentioned is

cell = cell_class(hidden_size)

If I add the input_size=input_size, the error about zero_state still exists. And I get another warning about the second parameter to BasicLSTMCell:

WARNING:tensorflow:<tensorflow.python.ops.rnn_cell.BasicLSTMCell object at 0x12d543710>: The input_size parameter is deprecated.

xslittlegrass avatar Mar 01 '17 03:03 xslittlegrass

@xslittlegrass Sorry, the correct one is: cell = cell_class(hidden_size)

I don't know how to solve your problem =/

The problem is in this function:

    def get_cell_zero_state(self, session, batch_size):
        return self.cell.zero_state(batch_size, tf.float32).eval(session=session)

but, self.cell.zero_state(batch_size, tf.float32) should not be a tuple. I try to run here and i didn't get this problem...

taleslimaf avatar Mar 01 '17 03:03 taleslimaf

@Atles That's strange. What version of tensorflow are you using?

xslittlegrass avatar Mar 01 '17 16:03 xslittlegrass

@xslittlegrass I'm using tensorflow 0.10.0.

taleslimaf avatar Mar 01 '17 16:03 taleslimaf

@Atles That's strange. I'm using version 0.11 and get the error. I'm seeing that self.cell.zero_state(batch_size, tf.float32) returns a tuple

(
LSTMStateTuple(c=<tf.Tensor 'zeros:0' shape=(85, 200) dtype=float32>, h=<tf.Tensor 'zeros_1:0' shape=(85, 200) dtype=float32>), 
LSTMStateTuple(c=<tf.Tensor 'zeros_2:0' shape=(85, 200) dtype=float32>, h=<tf.Tensor 'zeros_3:0' shape=(85, 200) dtype=float32>)
)

Do you have any ideas?

xslittlegrass avatar Mar 02 '17 00:03 xslittlegrass

@xslittlegrass well, i don't know if this is releted with the problem, but using my version of tensor flow, I get a warning.

WARNING:tensorflow:<tensorflow.python.ops.rnn_cell.BasicLSTMCell object at 0x7f69b385b0d0>: Using a concatenated state is slower and will soon be deprecated. Use state_is_tuple=True.

Maybe in your version of tensorflow this become a problem.

taleslimaf avatar Mar 03 '17 16:03 taleslimaf

@Atles hello , i have another problem

Traceback (most recent call last): File "main.py", line 17, in <module> rnn.train_model() File "/home/derek/AI_Composer/rnn.py", line 129, in train_model train_model = model_class(config, training=True) File "/home/derek/AI_Composer/model.py", line 64, in __init__ self.cell = tf.nn.rnn_cell.MultiRNNCell( AttributeError: 'module' object has no attribute 'rnn_cell'

do you know how to fix these , and thx for this fix

my tensorflow is 1.0.1

DerekQQQ avatar Apr 07 '17 14:04 DerekQQQ

@DerekQQQ What version of tensorflow are you using?

taleslimaf avatar Apr 10 '17 01:04 taleslimaf

@Atles after i change tensorflow to r10 it is all fixed but i used 3.5 hr to train the model , is it right?!

THX

DerekQQQ avatar Apr 10 '17 14:04 DerekQQQ