show_and_tell.tensorflow icon indicating copy to clipboard operation
show_and_tell.tensorflow copied to clipboard

ImportError: This module is deprecated. Use tf.nn.rnn_cell instead.

Open ilovezhenzhen opened this issue 8 years ago • 7 comments

ImportError: This module is deprecated. Use tf.nn.rnn_cell instead.

use from tensorflow.python.ops import rnn_cell but ValueError: setting an array element with a sequence.

ilovezhenzhen avatar Dec 15 '16 01:12 ilovezhenzhen

You can just revise the code in initial function: change self.lstm = xxxxx into self.lstm = tf.nn.rnncell.BasicLSTMCell(xxx), and delete from tf.model.nn import rnn_cell

YuDeng avatar Dec 22 '16 03:12 YuDeng

I still get ValueError: setting an array element with a sequence. after:

           self.lstm = tf.nn.rnn_cell.BasicLSTMCell(dim_hidden)

using TF 0.11.0, I get this:

Using TensorFlow backend.
Traceback (most recent call last):
  File "recog.py", line 33, in <module>
    fc7_tf, generated_words_tf = caption_generator.build_generator(maxlen=maxlen)
  File "..../show_and_tell.tensorflow.orig/model.py", line 95, in build_generator
    state = tf.zeros([1, self.lstm.state_size])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1184, in zeros
    shape = ops.convert_to_tensor(shape, dtype=dtypes.int32, name="shape")
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 657, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 180, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 163, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 354, in make_tensor_proto
    nparray = np.array(values, dtype=np_dt)
ValueError: setting an array element with a sequence.

Spiritdude avatar Jan 25 '17 10:01 Spiritdude

@ilovezhenzhen @Spiritdude
i have same proplem. do you have resolved it?
ValueError: setting an array element with a sequence.

xieqiangqiang avatar Feb 26 '17 15:02 xieqiangqiang

same problem as above. Do you have resolved it? @xieqiangqiang @Spiritdude @YuDeng

ecilay avatar Mar 31 '17 23:03 ecilay

+1,have someone fixed the ValueError?

Hitagi-Hu avatar May 11 '17 12:05 Hitagi-Hu

Use below lines in model.py

from tensorflow.contrib.rnn import BasicLSTMCell
from tensorflow.contrib.keras import preprocessing

karaanil avatar May 17 '17 22:05 karaanil

import tensorflow as tf tf

then you will get the location of tensorflow in you compute. you can find the responding file path in your tensorflow.

For me (tensorflow 1.5.0 version),the location are from tensorflow.contrib.rnn.python.ops import rnn_cell from tensorflow.contrib.keras.api.keras.preprocessing import sequence

Jason-xin avatar May 14 '18 11:05 Jason-xin