비슷한 스레드를 모두 확인했지만 문제를 해결할 수 없습니다.ValueError : tensorflow와 함께 배열을 사용하여 배열 요소를 설정하는 중
사실 내 코드는 내 로컬 시스템에서 제대로 작동하지만 서버에서 실행하면이 오류가 발생합니다. 코드 스 니펫 :
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 = []
역 추적 :
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.
여기에 실제 코드에 대한 링크입니다 - https://github.com/inikdom/neural-sentiment/blob/master/train.py
이 오류가 때문에 NumPy와 버전? 이전에 내 서버 numpy 버전은 1.11.2 였으므로 설치 제거하고 설치하십시오. 1.11.1
로컬 시스템의 오류없이 정상적으로 작동하는 1.11.1이 있습니다.
솔루션을 참조 : tensorflow: ValueError: setting an array element with a sequence
내가 np
와 tf
를 교체했지만,이
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
감사합니다. 그러나 이해하지 못했습니다. 너는 정교하게 만들어 줄 수 있니? – user123