-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add chunk eval layer #6296
add chunk eval layer #6296
Conversation
… trunk-evaluator
python/paddle/v2/fluid/layers.py
Outdated
@@ -632,6 +632,40 @@ def accuracy(input, label, k=1, correct=None, total=None, **kwargs): | |||
return acc_out | |||
|
|||
|
|||
def trunk_eval(input, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chunk_eval
should be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
images = layers.data(name='pixel', shape=[784], dtype='float32') | ||
label = layers.data(name='label', shape=[1], dtype='int32') | ||
hidden = layers.fc(input=images, size=128) | ||
crf = layers.linear_chain_crf( | ||
input=hidden, label=label, param_attr=ParamAttr(name="crfw")) | ||
crf_decode = layers.crf_decoding( | ||
input=hidden, param_attr=ParamAttr(name="crfw")) | ||
layers.trunk_eval( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chunk_eval
might be better.
@@ -173,10 +179,13 @@ def main(): | |||
for data in train_data(): | |||
outs = exe.run(fluid.default_main_program(), | |||
feed=feeder.feed(data), | |||
fetch_list=[avg_cost]) | |||
fetch_list=[avg_cost, precision]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe recall
and f1_score
can also be added here.
@@ -130,13 +130,19 @@ def test_word_embedding(self): | |||
def test_linear_chain_crf(self): | |||
program = Program() | |||
with program_guard(program, startup_program=Program()): | |||
label_dict_len = 10 | |||
images = layers.data(name='pixel', shape=[784], dtype='float32') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally suggest using NLP related names rather than names for images here, but it has little effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fix: #6280