【发布时间】:2018-08-06 10:40:20
【问题描述】:
我正在尝试在 python 3.5 中训练我的 RNN-LSTM 模型,这是我的代码,我的数据集是一个 3D 加速度计数据集
X = tf.placeholder(tf.float32, [None, config.n_steps, config.n_inputs])
Y = tf.placeholder(tf.float32, [None, config.n_classes])
with tf.Session() as sess:
tf.global_variables_initializer().run()
for epoch in range(training_epochs):
cost_history = np.empty(shape=[0],dtype=float)
for b in range(total_batches):
offset = (b * config.batch_size) % (train_y.shape[0] - config.batch_size)
batch_x = train_x[offset:(offset + config.batch_size), :, :]
batch_y = train_y[offset:(offset + config.batch_size), :]
print ("batch_x shape =",batch_x.shape)
print ("batch_y shape =",batch_y.shape)
_, c = sess.run([optimizer, cost],feed_dict={X: batch_x, Y : batch_y})
cost_history = np.append(cost_history,c)
loss_over_time[epoch] = np.mean(cost_history)
但它给了我以下错误
Traceback (most recent call last):
File "C:\Users\hp\Downloads\Deep-Learning-for-Human-Activity-Recognition-master\ModelCreation\RNN\FFLSTM\fflstm.py", line 250, in <module>
_, c = sess.run([optimizer, cost],feed_dict={X: batch_x, Y : batch_y})
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 895, in run
run_metadata_ptr)
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1100, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (64, 25, 9) for Tensor 'Placeholder:0', which has shape '(?, 25, 25)'
这是我的数据集的形状
n_inputs len(X_train[0][0]) 25
batch_x shape = (64, 25, 9)
batch_y shape = (64, 2)
X <tf.Tensor 'Placeholder:0' shape=(?, 25, 25) dtype=float32>
Y <tf.Tensor 'Placeholder_1:0' shape=(?, 2) dtype=float32>
【问题讨论】:
标签: python-3.x tensorflow signal-processing placeholder