machine-learning - LSTM 批处理与时间步

标签 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)

最佳答案

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

关于machine-learning - LSTM 批处理与时间步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42010966/

相关文章:

python - Entry_point 脚本存储在自定义 Sagemaker 框架训练作业容器中的什么位置?

python - tensorflow ,删除重复项

python - ValueError : Error when checking input: expected lstm_1_input to have 3 dimensions, 但得到形状为 (393613, 50) 的数组

python - LSTM Keras 网络的恒定输出和预测语法

python - LSTM 的 model.reset_states 会影响模型中的任何其他非 LSTM 层吗?

machine-learning - PCA(主成分分析)和特征选择之间的区别

algorithm - ID3算法修改

r - 使用 mlr-package 构建模型时的自定义性能测量

tensorflow - 为什么在 Google Cloud ML 上训练的 TensorFlow 模型比本地训练的模型更准确?

python - Tensorflow Keras LSTM 未训练 - 受 number_of_epochs、优化器 a​​dam 影响