Skip to content
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 label semantic examples with new Fluid api #10368

Merged

Conversation

sidgoyal78
Copy link
Contributor

Issues:

@sidgoyal78 sidgoyal78 requested review from helinwang, cs2be, wangkuiyi, cxysteven, reyoung and abhinavarora and removed request for cs2be and cxysteven May 3, 2018 06:10


def inference_network():
word = fluid.layers.data(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put data layer definitions into lstm_net?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

mark_dict_len = 2

def lstm_net(word, predicate, ctx_n2, ctx_n1, ctx_0, ctx_p1, ctx_p2, mark,
**ignored):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need **ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks.

return crf_decode

def train_network():
mix_hidden_lr = 1e-3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the constants in this file is upper case snake case (BATCH_SIZE), some are snake case (mix_hidden_lr). Could you change all constants to upper case snake case (BATCH_SIZE)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

event.batch_id + 1, avg_cost))

if avg_cost > 0.01: # Low threshold for speeding up CI
trainer.params.save(save_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def infer(use_cuda, save_path):
params = fluid.Params(save_path)
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
inferencer = fluid.Inferencer(inference_network, params, place=place)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

@sidgoyal78 sidgoyal78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Helin for the review. I just made a few changes. Can you please take a look?

@helinwang helinwang added this to In Progress in Fluid API Simplification May 4, 2018
Copy link
Contributor

@helinwang helinwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, LGTM otherwise. Thank you!

if (event.batch_id % 10) == 0:
avg_cost = trainer.test(reader=test_reader)

print('BatchID {1:04}, Loss {2:2.2}'.format(event.batch_id + 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be BatchID {0:04}, Loss {1:2.2}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@jetfuel jetfuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The new API is so clean.

@sidgoyal78 sidgoyal78 merged commit 8a8ae9c into PaddlePaddle:develop May 7, 2018
@sidgoyal78 sidgoyal78 mentioned this pull request May 7, 2018
@jetfuel jetfuel moved this from In Progress to Done in Fluid API Simplification May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants