2017-08-09 38 views
0

我正在使用Pomegranate library來實現HMM。我下面什麼文件說使用from_samples函數說參數labels之一應該是:石榴HMM標籤:具有多個元素的數組的真值是不明確的。

An array of state labels for each sequence. This is only used in ‘labeled’ training. If used this must be comprised of n lists where n is the number of sequences to train on, and each of those lists must have one label per observation. Default is None.

我的代碼是:

model = HiddenMarkovModel('Gestures').from_samples(
     NormalDistribution, 3, training, labels=[0, 1, 2], algorithm='labeled') 

我得到的錯誤:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() 

這是沒有意義,因爲我輸入數組,但我想它認爲我應該輸入布爾?

回答

0

我想你可能誤解了文檔。 labels必須是您的training集合的長度標籤列表(不是現在看起來的州數)。然後,如果您的訓練集包含N序列,則作爲labels傳遞的列表的長度應爲N.

您不確切地說明您的訓練集是什麼,但是這兩個變量的長度不一致可能會引發這種錯誤(儘管我不是Python的專家)。

相關問題