初始化 HiddenMarkovModelTrainer 对象

发布于 2024-12-28 10:40:29 字数 970 浏览 0 评论 0原文

我正在用Python进行手势识别,我发现的可以管理隐马尔可夫模型的更完整的库之一是nltk。但有件事我无法理解。

首先是数据。我有手势的坐标,并将它们分为 8 个簇(使用 k 均值)。所以这是我的手势结构:

raw coordinates x,y: [[123,16], [120,16], [115,16], [111,16], [107,16], [103,17], ...]

centroids x,y : [[ 132.375        56.625     ]
                 [ 122.45454545   30.09090909]
                 [  70.5          27.33333333]
                 ...]

labels: [5 6 6 6 6 6 6 2 2 2 2 2 2 4 4 4 ...]

现在我想用 Baum-Welch 和我的 .所以 HiddenMarkovModelTrainer 是我的课程。

我在互联网上发现了一些 baum welch 的更多实现,但仅限于 Matlab。该算法的实现通常需要以下输入

baum-welch(X, alphabet, H)

: - X 是火车的数据(在我的例子中 - 标签) - 用字母表表示数据的可能值(在我的例子中 - 0,1,2,3,4,5,6,7) - H 隐藏状态的数量

现在我很困惑,因为在 ntlk.HiddenMarkovModelTrainer 构造函数中我必须给出 状态符号 并且我不知道它们应该是什么,考虑到训练 X 的数据是 HiddenMarkovModelTrainer.train_unsupervised() 方法的输入,我认为我的字母表是符号..我不知道要在状态中放入什么。

即使我的英语很差,我希望我的解释很清楚。

i'm doing gesture recognition in python and one the the more complete library i've found that can manage Hidden Markov Model is nltk. But there is something that i can't understand.

First of all, the data. I have coordinates of the gesture and i have clustized them in 8 cluster (with k-means). so this is my gesture structure:

raw coordinates x,y: [[123,16], [120,16], [115,16], [111,16], [107,16], [103,17], ...]

centroids x,y : [[ 132.375        56.625     ]
                 [ 122.45454545   30.09090909]
                 [  70.5          27.33333333]
                 ...]

labels: [5 6 6 6 6 6 6 2 2 2 2 2 2 4 4 4 ...]

Now i want to train an HMM with Baum-Welch with my . So HiddenMarkovModelTrainer is my class.

I've found in internet some few more implementations of baum welch, but only in Matlab. the implementation of this algorithms tipically need this input:

baum-welch(X, alphabet, H)

where
- X is the data for train (in my case - labels)
- alphabet the possible values of the data (in my case - 0,1,2,3,4,5,6,7)
- H the number of hidden states

Now i am confused because in ntlk.HiddenMarkovModelTrainer constructor i have to give states and symbols and i don't know what they should be, considering that the data to train X is the imput of HiddenMarkovModelTrainer.train_unsupervised() method i think that my alphabet is symbol.. i don't know what to put in states.

i hope my explanation is clear even if my english is poor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦境 2025-01-04 10:40:29

隐马尔可夫模型之所以被称为隐马尔可夫模型,是因为它们的实际状态是不可观测的;相反,各州以一定的概率产生观察结果。 HMM 在 NLTK 中的经典用法是词性标记,其中观察结果是单词,隐藏的内部状态是词性标记。请查看此示例,了解说明的内容< /code> 和 symbols 参数在这种情况下意味着。

对于使用 HMM 进行手势识别,观察结果是几何输入数据的某种特征建模(符号)的时间序列 - 在您的情况下,您使用聚类(也称为“分区”) - 请参阅 本节的 3.2 节论文(“Yang, Xu. Hidden Markov Model for Gesture Recognition”) 对于其他一些可能的模型)。据我了解,内部状态集没有任何有意义的解释。每个手势的 HMM 训练中使用的内部状态数量只是一个必须进行实验的参数。有关示例,请参阅本文(“Yamato,Ohya ,Ishii。使用 HMM 识别时间序列图像中的人类行为”) - 状态数设置为 36,这被批评为过高。 这篇硕士论文,只是举一个可修改参数的例子。

所以我会用这段代码尝试一下:

observed_sequence = [5, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 4, 4, 4]
states = range(20) # experiment with this number
symbols = set(observed_clusters)
trainer = HiddenMarkovModelTrainer(states, symbols)
model = trainer.train_unsupervised([observed_sequence])

Hidden Markov Models are called so because their actual states are not observable; instead, the states produce an observation with a certain probability. The classical use of HMMs in the NLTK is POS tagging, where the observations are words and the hidden internal states are POS tags. Look at this example to understand what the states and symbols parameters mean in this case.

For gesture recognition with HMM, the observations are temporal sequences of some kind of feature modeling (symbols) of the geometrical input data - in your case, you use clustering (also called "zoning" - see section 3.2 of this paper ("Yang, Xu. Hidden Markov Model for Gesture Recognition") for some other possible models). To my understanding, the set of internal states doesn't have any meaningful interpretation. The number of internal states used in the training of an HMM for each gesture is simply a parameter that has to be experimented with. For an example, see this paper ("Yamato, Ohya, Ishii. Recognizing Human Action in Time-Sequential Images using HMM") - the number of states is set to 36, which is criticized as being too high in this master thesis, just to cite an example of this being a modifiable parameter.

So I would try it with this code:

observed_sequence = [5, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 4, 4, 4]
states = range(20) # experiment with this number
symbols = set(observed_clusters)
trainer = HiddenMarkovModelTrainer(states, symbols)
model = trainer.train_unsupervised([observed_sequence])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文