使用 pyro 的深度生成模型中 mini batch 的概念

Concept of mini batch in deep generative model using pyro

我是概率编程和 ML 的新手。我正在关注 pyro 网站上给出的关于深度马尔可夫模型的代码。该代码的 github 页面的 link 是:

https://github.com/pyro-ppl/pyro/blob/dev/examples/dmm/dmm.py

我理解大部分代码。我不明白的部分是他们从第 175 行开始使用的小批量想法。

问题 1: 有人可以解释一下他们在使用小批量时在那里做什么吗?

他们在 pyro 文档中说

mini_batch is a three dimensional tensor, with the first dimension being the batch dimension, the second dimension being the temporal dimension, and the final dimension being the features (88-dimensional in our case)'

问题二: 这里的时间维度是什么意思?

因为我想在我的数据集上使用这段代码,这是一个顺序数据。我对我的数据进行了一次热编码,使其维度为 (10000,500,20),其中 10000 是 examples/Sequences 的数量,500 是每个的长度这些序列和 20 是特征的数量。

问题三: 如何在这里将我的一个热编码数据用作小批量?

如果这是一个非常基本的问题,我很抱歉,但是,我们将不胜感激。

Link 该文档是:

https://pyro.ai/examples/dmm.html

Question 1: Could someone explain what are they doing there when they are using mini-batch?

为了优化大多数深度学习模型,我们使用了小批量梯度下降。这里,Amini_batch指的是少量的例子。比方说,我们有 10,000 个训练示例,我们想要创建 50 个示例的小批量。因此,总共将有 200 个小批量,我们将在整个数据集的一次迭代中执行 200 次参数更新。

Question 2: What does the temporal dimension mean here?

在你的数据中:(10000, 500, 20),第二个维度是指时间维度。您可以认为您有 500 个时间步长的示例 (t1, t2, ..., t500).

Question 3: How can I use my one-hot encoded data as mini-batch here?

在您的方案中,您可以将数据 (10000, 500, 20) 分成 200 个大小为 (50, 500, 20) 的小批,其中 50 是小批中 examples/Sequences 的数量,500 是每个序列的长度,20 是特征的数量。

我们如何决定小批量的大小?基本上,我们可以像调整模型的任何其他超参数一样调整批量大小。