我正在学习如何使用LSTM RNN。 我看到了本教程:https://www.youtube.com/watch?v=SeffmcG42SY& 之后,我尝试应用所学知识并更改数据集。 问题是,我有点失去了所有的重塑,我真的不知道如何使用它们,为什么他们在这里... 我的数据集有7列和546行。 这里是我的超参数LSTM张量形状和超参数Tensorflow
# hyperparameters
lr = 0.001
training_iters = 100000
batch_size = 64
n_inputs = 7 # columns
n_steps = 546 # rows
n_hidden_units = 128 # neurons in hidden layer
n_classes = 1 # class
当我启动我的会议,它看起来像这样:
with tf.Session() as sess:
init = tf.global_variables_initializer()
sess.run(init)
step = 0
while step * batch_size < training_iters:
batch_xs, batch_ys = inputX, inputY
batch_xs = batch_xs.reshape([batch_size, n_steps, n_inputs])
sess.run([train_op], feed_dict={
x: batch_xs,
y: batch_ys,
})
if step % 20 == 0:
print(sess.run(accuracy, feed_dict={
x: batch_xs,
y: batch_ys,
}))
step += 1
然后,我有一个错误消息
“不能重塑尺寸3822型数组形状(64,546,7)“
如果有人能解释我该如何工作和/或如何解决问题,那将非常棒!
谢谢
为什么不打印张量形状以查看它们的尺寸? –
输入应该是'[batch_size,time_steps,sample_dim]'。在你的数据集中,我假设每一行都有一个长度为7的序列数据。因此,选择N行将是你的'batch_size','time_steps'是7,如果它的'one-hot'编码向量是'sample_dim', –
那么,我的批量大小是x:(546,7)和y:(546,1)。我的功能不是很热,所以如果我明白了,我不会有一个样本暗淡的参数? –