0

我正在https://github.com/udacity/AIND-Recognize上的 GitHub 上进行手语识别。

我有一个关于模型选择的问题。当我在那里运行这个单元格时

import warnings 
from hmmlearn.hmm import GaussianHMM

def train_a_word(word, num_hidden_states, features):
    warnings.filterwarnings("ignore", category=DeprecationWarning)
    training = asl.build_training(features)  
    X, lengths = training.get_word_Xlengths(word)
    model = GaussianHMM(n_components=num_hidden_states, n_iter=1000).fit(X, lengths)
    logL = model.score(X, lengths)
    return model, logL

demoword = 'BOOK'
model, logL = train_a_word(demoword, 3 , features=features_ground)
print("Number of states trained in model for {} is {}".format(demoword, model.n_components))
print("logL = {}".format(logL))

我有这个错误:

TypeError Traceback (most recent call last) in () 12  13 demoword = 'BOOK' ---> 14 model, 
  logL = train_a_word(demoword, 3 , features=features_ground) 15 print("Number of states 
  trained in model for {} is {}".format(demoword, model.n_components)) 
  16 print("logL = {}".format(logL)) in train_a_word(word, num_hidden_states, features) 
  7 training = asl.build_training(features) 8 X, lengths = training.get_word_Xlengths(word) 
  ----> 9 model = GaussianHMM(n_components=num_hidden_states, n_iter=1000).fit(X, lengths) 
  10 logL = model.score(X, lengths) 11 return model, logL

TypeError: fit() takes 2 positional arguments but 3 were given

我想不通,我想提一下,我们不应该修改这个单元格。

4

2 回答 2

0

尝试更新您的依赖项,尤其是 hmmlearn 和 scikit-learn。您可以在这里找到完整的项目以供将来参考: https ://github.com/llSeedll/Udacity-AIND/tree/master/Project%204%20-%20ASLRecognizer

于 2018-05-22T11:40:05.380 回答
0

问题是你的线路引起的

model = GaussianHMM(n_components=num_hidden_states, n_iter=1000).fit(X, lengths)

解决问题:
更改fit(X, lengths)fit(X, lengths=lengths)

请参阅hmmlearn文档
关于参数的可能有用的答案

于 2017-06-17T09:45:54.450 回答