Sephora-M / chord2vec

From word2vec to chord2vec tensorFlow implementation
26 stars 2 forks source link

rnn.rnn is deprecated #3

Open yogeshg opened 7 years ago

yogeshg commented 7 years ago

rnn.rnn is used in https://github.com/Sephora-M/chord2vec/blob/master/chord2vec/seq2seq/seq2seqs_model.py#L441

but according to https://github.com/tensorflow/tensorflow/issues/8836 I should either use dynamic_rnn, that matches the signature of the function or raw_rnn which doesn't. I tried using dynamic_rnn and ran into the following error:

  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 710, in main
    train()
  File "main.py", line 380, in train
    model = create_seq2seqs_model(sess, False)
  File "main.py", line 282, in create_seq2seqs_model
    FLAGS.learning_rate_decay_factor)
  File "/some/path/repo/chord2vec/chord2vec/seq2seq/seq2seqs_model.py", line 100, in __init__
    buckets, lambda x,y: embedding_rnn_seq2seqs(x,num_decoders,y,cell,
  File "/some/path/repo/chord2vec/chord2vec/seq2seq/seq2seqs_model.py", line 563, in model_with_buckets
    decoders_inputs)
  File "/some/path/repo/chord2vec/chord2vec/seq2seq/seq2seqs_model.py", line 102, in <lambda>
    embedding_size=num_units))
  File "/some/path/repo/chord2vec/chord2vec/seq2seq/seq2seqs_model.py", line 441, in embedding_rnn_seq2seqs
    _, encoder_state = rnn.dynamic_rnn(encoder_cell, encoder_inputs, dtype=dtype)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 489, in dynamic_rnn
    for input_ in flat_input)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 489, in <genexpr>
    for input_ in flat_input)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1288, in transpose
    ret = gen_array_ops.transpose(a, perm, name=name)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3841, in transpose
    result = _op_def_lib.apply_op("Transpose", x=x, perm=perm, name=name)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
    op_def=op_def)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2397, in create_op
    set_shapes_for_outputs(ret)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1757, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1707, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
    debug_python_shape_fn, require_shape_fn)
  File "/some/path/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 675, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimension must be 1 but is 3 for 'model/model_with_buckets/model/embedding_rnn_seq2seq/transpose' (op: 'Transpose') with input shapes: [?], [3].

could you guide me what's the intended use for the rnn?

Sephora-M commented 7 years ago

I believe that with the latest versions of TF you can now directly call the cell in order to process the rnn. The only difference will be that you'll need an initial state _encorderstate for it to work. Try something like this:

_, encoder_state = encoder_cell(encoder_inputs, encoder_state)