当我尝试来自http://nltk.googlecode.com/svn/trunk/doc/howto/classify.html的MaxentClassifier示例时,我得到了以下错误:
等级评估0
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
classifier = MaxentClassifier.train(train)
File "C:\Python27\lib\site-packages\nltk\classify\maxent.py", line 323, in train
gaussian_prior_sigma, **cutoffs)
File "C:\Python27\lib\site-packages\nltk\classify\maxent.py", line 1456, in train_maxent_classifier_with_scipy
model.fit(algorithm=algorithm)
File "C:\Python27\lib\site-packages\scipy\maxentropy\maxentropy.py", line 1026, in fit
return model.fit(self, self.K, algorithm)
File "C:\Python27\lib\site-packages\scipy\maxentropy\maxentropy.py", line 226, in fit
callback=callback)
File "C:\Python27\lib\site-packages\scipy\optimize\optimize.py", line 636, in fmin_cg
gfk = myfprime(x0)
File "C:\Python27\lib\site-packages\scipy\optimize\optimize.py", line 176, in function_wrapper
return function(x, *args)
File "C:\Python27\lib\site-packages\scipy\maxentropy\maxentropy.py", line 420, in grad
G = self.expectations() - self.K
ValueError: operands could not be broadcast together with shapes (54) (12)
Python代码:
^{pr2}$但我不知道怎么解决。 帮帮我,谢谢!在
如果您设置了算法,则会起作用:
(请注意,您错过了培训语料库中的一行)
编辑:一些nltk算法失败,包括“CG”。问题可能与报告的here相同。如果是这种情况,可能会在nltk的下一个版本中解决。您也可以向nltk报告一个bug,以帮助开发人员和您自己。在
由于报告的bug似乎与numpy广播和numpy的过时用法有关,也许您可以尝试使用一个旧版本的numpy
相关问题 更多 >
编程相关推荐