LSTM批次与时间步

时间:2017-02-02 19:41:42

标签: machine-learning tensorflow lstm

我已经按照TensorFlow RNN教程创建了LSTM模型。然而,在这个过程中,我对'批次'和'时间步'之间的差异(如果有的话)感到困惑,我很感激帮助澄清这个问题。

教程代码(见下文)基本上根据指定的步骤创建“批次”:

with tf.variable_scope("RNN"):
      for time_step in range(num_steps):
        if time_step > 0: tf.get_variable_scope().reuse_variables()
        (cell_output, state) = cell(inputs[:, time_step, :], state)
        outputs.append(cell_output)

但是,以下似乎也是如此:

    for epoch in range(5):
        print('----- Epoch', epoch, '-----')
        total_loss = 0
        for i in range(inputs_cnt // BATCH_SIZE):
            inputs_batch = train_inputs[i * BATCH_SIZE: (i + 1) * BATCH_SIZE]
            orders_batch = train_orders[i * BATCH_SIZE: (i + 1) * BATCH_SIZE]
            feed_dict = {story: inputs_batch, order: orders_batch}

            logits, xent, loss = sess.run([...], feed_dict=feed_dict)

1 个答案:

答案 0 :(得分:1)

假设您正在使用文本,BATCH_SIZE将是您并行处理的句子数,num_steps将是任何句子中的最大单词数。这些是您输入LSTM的不同尺寸。