我正在 GitHub 上研究手语识别,https://github.com/udacity/AIND-Recognize 这里提供。
我在模型选择量规上遇到问题。当我在那里运行这个单元格时
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
我想不通,我想提一下,我们不应该修改这个单元格。
问题是由您的线路引起的
model = GaussianHMM(n_components=num_hidden_states, n_iter=1000).fit(X, lengths)
要解决此问题,请执行以下操作:
更改fit(X, lengths=lengths)
的fit(X, lengths)
请参阅hmmlearn
文档
关于论点的可能有用的答案
尝试更新你的依赖项,特别是hmmlearn和scikit-learn。您可以在此处找到完整的项目以供将来参考:https://github.com/llSeedll/Udacity-AIND/tree/master/Project%204%20-%20ASLRecognizer