所以我的任务是预测序列。我在时间 t 有 x,y,z 值,它们是浮点型。我必须预测在时间 (t + 1) 具有值 x,y,z 的序列。TIME_STEP = 10N_FEATURES = N_CLASSES = 3LEARNING_RATE = 0.01EPOCHS = 50BATCH_SIZE = 10x = tf.placeholder(tf.float32, shape = [None, N_FEATURES], name = 'name')y = tf.placeholder(tf.float32, shape = [N_CLASSES], name = 'labels')然后我有我的 lstm 模型,它看起来像: x = tf.transpose(x, [1, 0]) x = tf.reshape(x, [-1, num_features]) hidden = tf.nn.relu(tf.matmul(x, self.h_W) + self.h_biases) hidden = tf.split(hidden, self.time_step) lstm_layers = [tf.contrib.rnn.BasicLSTMCell(self.hidden_units, forget_bias=1.0) for _ in range(2)] lstm_layers = tf.contrib.rnn.MultiRNNCell(lstm_layers) outputs, _ = tf.contrib.rnn.static_rnn(lstm_layers, hidden, dtype = tf.float32) lstm_output = outputs[-1]最后我定义了损失函数和优化器loss = tf.reduce_mean(tf.square(y - y_pred))opt = tf.train.AdamOptimizer(learning_rate = LEARNING_RATE).minimize(loss)现在我想用前 10 个值来预测第 11 个值。所以我运行会话for time in range(0, len(X)): sess.run(opt, feed_dict = {x : X[time: time + TIME_STEP ], y : Y[time + TIME_STEP + 1]})但是当我检查这个函数的损失时,它有很大的价值,比如 99400290.0,它会随着时间的推移而增加。这是我第一次预测序列,所以我想我一定遗漏了一些重要的东西
1 回答

莫回无
TA贡献1865条经验 获得超7个赞
是的,您应该标准化您的真实世界输入数据,并且它应该使用您在训练集上使用的相同缩放(相同参数)。
原因是,现在您的模型已接受训练以接受特定形状和比例的输入,并且要使其按预期执行,您必须将测试输入扩展到它。
(很抱歉将此作为答案发布,没有足够的代表发表评论)
添加回答
举报
0/150
提交
取消