PyStruct - 没有匹配的签名查找

the*_*yew 4 python python-2.7 multilabel-classification

我正在尝试使用此处的代码:https://github.com/pystruct/pystruct/blob/master/examples/multi_label.py

我有X_train的形状(2591, 256)和y_train的形状(2591, 175).当我运行这个:

tree = chow_liu_tree(y_train)
tree_model = MultiLabelClf(edges=tree, inference_method="max-product")
tree_ssvm = OneSlackSSVM(tree_model, inference_cache=50, C=.1, tol=0.01)
print("fitting tree model...")
tree_ssvm.fit(X_train, y_train)
Run Code Online (Sandbox Code Playgroud)

我懂了:

Traceback (most recent call last):
  File "classifiers.py", line 173, in <module>
    tree_ssvm.fit(X_train, y_train)
  File "/usr/local/lib/python2.7/dist-packages/pystruct/learners/one_slack_ssvm.py", line 448, in fit
    X, Y, joint_feature_gt, constraints)
  File "/usr/local/lib/python2.7/dist-packages/pystruct/learners/one_slack_ssvm.py", line 348, in _find_new_constraint
    X, Y, self.w, relaxed=True)
  File "/usr/local/lib/python2.7/dist-packages/pystruct/models/base.py", line 95, in batch_loss_augmented_inference
    for x, y in zip(X, Y)]
  File "/usr/local/lib/python2.7/dist-packages/pystruct/models/crf.py", line 106, in loss_augmented_inference
    loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found
Run Code Online (Sandbox Code Playgroud)

当我直接从链接运行代码时,它(与他们的数据集)一起工作.有人知道应该是什么问题吗?

the*_*yew 7

如果有人也会得到那个错误,y必须是int类型 - 我得到浮动.

解决方案链接:https://groups.google.com/forum/#!searchin/pystruct/matching/pystruct/T6UKEgZLmxY/297oLYQL8U8J