Ich habe alle ähnlichen Threads überprüft, konnte aber mein Problem nicht beheben.ValueError: Setzen eines Array-Elements mit einer Sequenz bei der Verwendung mit Tensorflow
Eigentlich funktioniert mein Code auf meinem lokalen System, aber wenn ich es auf dem Server ausführe, gibt es diesen Fehler. Codeausschnitt:
with tf.variable_scope("lstm") as scope:
# The RNN cell
single_cell = rnn_cell.DropoutWrapper(
rnn_cell.LSTMCell(hidden_size, hidden_size, initializer=tf.random_uniform_initializer(-1.0, 1.0)),
input_keep_prob=self.dropout_keep_prob_lstm_input,
output_keep_prob=self.dropout_keep_prob_lstm_output)
self.cell = rnn_cell.MultiRNNCell([single_cell] * num_layers)
# Build the recurrence. We do this manually to use truncated backprop
self.initial_state = tf.zeros([self.batch_size, self.cell.state_size]) # ERROR IS IN THIS LINE
self.encoder_states = [self.initial_state]
self.encoder_outputs = []
Traceback:
WARNING:tensorflow:<tensorflow.python.ops.rnn_cell.LSTMCell object at 0x7f56e6c2cb10>: The input_size parameter is deprecated.
Traceback (most recent call last):
File "train.py", line 194, in <module>
main()
File "train.py", line 63, in main
model = create_model(sess, hyper_params, vocab_size)
File "train.py", line 124, in create_model
hyper_params["batch_size"])
File "/home/datametica/karim/deeplearning/neural-sentiment/models/sentiment.py", line 73, in __init__
self.initial_state = tf.zeros([self.batch_size, self.cell.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.
Hier Link zum eigentlichen Code - https://github.com/inikdom/neural-sentiment/blob/master/train.py
Ist dieser Fehler aufgrund numpy Version? Früher mein Server numpy Version war 1.11.2, also ich deinstalliert und installieren numpy 1.11.1
Mein lokales System hat 1.11.1, die ohne Fehler einwandfrei funktioniert.
Mit Bezug auf Lösung: tensorflow: ValueError: setting an array element with a sequence
Ich versuchte tf
mit np
ersetzen, aber es gab
WARNING:tensorflow:<tensorflow.python.ops.rnn_cell.LSTMCell object at 0x7f84f6f8e890>: The input_size parameter is deprecated.
Traceback (most recent call last):
File "train.py", line 194, in <module>
main()
File "train.py", line 63, in main
model = create_model(sess, hyper_params, vocab_size)
File "train.py", line 124, in create_model
hyper_params["batch_size"])
File "/home/datametica/karim/deeplearning/neural-sentiment/models/sentiment.py", line 73, in __init__
self.initial_state = np.zeros([self.batch_size, self.cell.state_size])
TypeError: an integer is required
Danke, aber ich habe es nicht verstanden. Kannst du bitte etwas ausarbeiten? – user123