Open ilovezhenzhen opened 7 years ago
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
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.
@ilovezhenzhen @Spiritdude
i have same proplem. do you have resolved it?
ValueError: setting an array element with a sequence.
same problem as above. Do you have resolved it? @xieqiangqiang @Spiritdude @YuDeng
+1,have someone fixed the ValueError?
Use below lines in model.py
from tensorflow.contrib.rnn import BasicLSTMCell
from tensorflow.contrib.keras import preprocessing
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
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.