【问题标题】:LSTM Batches vs TimestepsLSTM 批次与时间步长
【发布时间】:2017-02-02 19:41:42
【问题描述】:

我已按照 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)

【问题讨论】:

    标签: machine-learning tensorflow lstm


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2018-03-09
      • 1970-01-01
      • 2020-08-24
      • 2022-01-24
      • 2022-01-14
      • 2019-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多