テンソルフローを初めて使用しています。私はこの実行すると:Tensorflowエラー:Tensor u'Placeholder_3:0 'のシェイプ(100,177,203)の形状に値'(?, 181,192) 'がありません
init = tf.global_variables_initializer()
init
n_epochs = 1000
batch_size = 100
n_batches = len(train_sequences) // batch_size
print(n_batches)
with tf.Session() as sess:
init.run()
for epoch in range(n_epochs):
train_sequences, train_y, train_lengths = shuffle(train_sequences, train_y, train_lengths)
for iteration in range(n_batches):
start = iteration*batch_size
end = start+batch_size
X_batch = train_sequences[start:end]
y_batch = train_y[start:end]
seq_length_batch = train_lengths[start:end]
if iteration % 20 == 0:
train_summary_str = train_summary_op.eval(
feed_dict = {X: X_batch, y: y_batch, seq_length: seq_length_batch}
)
step = epoch * n_batches + iteration
train_writer.add_summary(train_summary_str, step)
train_writer.flush()
if iteration % 200 == 0:
summary_str = eval_summary_op.eval(
feed_dict = {X: test_sequences, y: test_y, seq_length: test_lengths}
)
step = epoch * n_batches + iteration
eval_writer.add_summary(summary_str, step)
eval_writer.flush()
sess.run(
training_op,
feed_dict = {X: X_batch, y: y_batch, seq_length: seq_length_batch}
)
acc_train = accuracy.eval(
feed_dict = {X: X_batch, y: y_batch, seq_length: seq_length_batch}
)
acc_test = accuracy.eval(
feed_dict = {X: test_sequences, y: test_y, seq_length: test_lengths}
)
print(epoch, "Train accuracy:", acc_train, "Test accuracy:", acc_test)
save_path = saver.save(sess, "/home/ubuntu/tensorflow/model.ckpt")
train_writer.close()
eval_writer.close()
を私は受けていますエラーがある:それはこのようになります
ValueError: Cannot feed value of shape (100, 177, 203) for Tensor u'Placeholder_3:0', which has shape '(?, 181, 192)'
は、エラーが生成されます場所です:
train_summary_str = train_summary_op.eval(
feed_dict = {X: X_batch, y: y_batch, seq_length: seq_length_batch}
)
更新: tfプレースホルダを定義している間に寸法を変更してエラーを修正しました。
tf.reset_default_graph()
n_steps = 177
n_inputs = 203
n_neurons = 100
n_outputs = 2
X = tf.placeholder(tf.float32, [None, n_steps, n_inputs])
y = tf.placeholder(tf.int32)
seq_length = tf.placeholder(tf.int32, [None])
basic_cell = tf.contrib.rnn.BasicRNNCell(num_units=n_neurons)
outputs, states = tf.nn.dynamic_rnn(basic_cell, X, dtype=tf.float32, sequence_length=seq_length)
完全なコードを表示できますか。具体的にはどこにプレースホルダを定義していますか?データロード –