【发布时间】:2018-08-14 12:33:31
【问题描述】:
我一直在使用 tensorflow 在 LSTM 上进行时间序列预测。现在,我想尝试序列到序列(seq2seq)。在官方网站上有一个教程展示了 NMT with embeddings 。那么,如何在没有嵌入的情况下使用这个新的 seq2seq 模块呢? (直接使用时间序列“序列”)。
# 1. Encoder
encoder_cell = tf.contrib.rnn.BasicLSTMCell(LSTM_SIZE)
encoder_outputs, encoder_state = tf.nn.static_rnn(
encoder_cell,
x,
dtype=tf.float32)
# Decoder
decoder_cell = tf.nn.rnn_cell.BasicLSTMCell(LSTM_SIZE)
helper = tf.contrib.seq2seq.TrainingHelper(
decoder_emb_inp, decoder_lengths, time_major=True)
decoder = tf.contrib.seq2seq.BasicDecoder(
decoder_cell, helper, encoder_state)
# Dynamic decoding
outputs, _ = tf.contrib.seq2seq.dynamic_decode(decoder)
outputs = outputs[-1]
# output is result of linear activation of last layer of RNN
weight = tf.Variable(tf.random_normal([LSTM_SIZE, N_OUTPUTS]))
bias = tf.Variable(tf.random_normal([N_OUTPUTS]))
predictions = tf.matmul(outputs, weight) + bias
如果我使用 input_seq=x 和 output_seq=label,TrainingHelper() 的参数应该是什么?
decoder_emb_inp ??? 解码器长度???
其中 input_seq 是序列的前 8 个点,而 output_seq 是序列的最后 2 个点。 提前致谢!
【问题讨论】:
-
你有没有找到答案?我正在遵循相同的教程并希望为时间序列数据实现它
-
嗨 MrfksIV!我刚刚找到本教程link,但它不使用不允许使用 ML Engine 的 TensorFlow API(可扩展的训练/在 GCP 上部署)。我希望本教程可以帮助您弄清楚如何为时间序列构建 seq2seq。如果您知道如何扩展到 TensorFlow API,请告诉我。
-
明天会看看这个,如果我找到任何东西,请告诉你。谢谢!
-
我找到了this,它帮助我构建了我想要的东西。我想它也能解决你的问题!
-
你取得好成绩了吗?我的意思是,与仅使用 LSTM 架构相比,它的性能更好。让我知道您是否获得了良好的结果以便对我的用例进行编码。
标签: tensorflow time-series forecasting