使用python预测工具, 如果output是id类型会出错
Created by: linrongyi
序列标注模型预测的时候, 如果ouput layer是id类型的, 例如 crf_decoding 或者 maxid
if use_crf:
Layer(
name = "%s_label" % name_,
type = "crf_decoding",
size = slot_conf_dict[name_]['dim'],
inputs = [
Input("output_%s" % name_, parameter_name="crfw_%s" % name_),
]
)
else:
Layer(
name = "%s_label" % name_,
type = "maxid",
inputs = "output_%s" % name_,
)
forwardTest会出错
raceback (most recent call last):
File "deep_tagger_new_paddle.py", line 87, in <module>
outputs = do_tag(text, conf='output_tag')
File "deep_tagger_new_paddle.py", line 57, in do_tag
outputs_ = networks[0].forwardTest(inst_)
File "/home/aladdin/.jumbo/lib/python2.7/site-packages/py_paddle/util.py", line 149, in forwardTest
for i in xrange(outArgs.getSlotNum())
File "/home/aladdin/.jumbo/lib/python2.7/site-packages/py_paddle/util.py", line 89, in __arguments_to_numpy__
if ids is not None:
UnboundLocalError: local variable 'ids' referenced before assignment
如果输出是概率分布, e.g.,
Layer(
name = "output_%s" % name_,
type = "mixed",
active_type = "softmax",
size = slot_conf_dict[name_]['dim'],
bias = False,
inputs = [
FullMatrixProjection("decoder_state_final_%s" % name_),
]
)
则不会出错. 这是为什么呢?