Skip to content

Comments

While op forward for sentimental analysis#6140

Merged
reyoung merged 9 commits intoPaddlePaddle:developfrom
reyoung:feature/while_op_sentiment_analysis
Dec 4, 2017
Merged

While op forward for sentimental analysis#6140
reyoung merged 9 commits intoPaddlePaddle:developfrom
reyoung:feature/while_op_sentiment_analysis

Conversation

@reyoung
Copy link
Collaborator

@reyoung reyoung commented Dec 1, 2017

Fix #6139

Also, Fix #6134, Fix #6135

Base on PR #6102

@reyoung reyoung changed the title Feature/while op sentiment analysis While op forward for sentimental analysis Dec 1, 2017
sentence = fluid.layers.data(
name='word', shape=[1], dtype='int64', lod_level=1)
sent_emb = fluid.layers.embedding(
input=sentence, size=[65535, 32], dtype='float32')
Copy link
Member

Choose a reason for hiding this comment

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

size = [len(self.word_dict), 32]

@reyoung reyoung force-pushed the feature/while_op_sentiment_analysis branch 2 times, most recently from c00349c to 6aae3ad Compare December 4, 2017 08:39
@reyoung reyoung force-pushed the feature/while_op_sentiment_analysis branch from 6aae3ad to bf38d85 Compare December 4, 2017 08:43
return false;
if (ctrl_flow_ops.find(ops[op_index]->Type()) !=
ctrl_flow_ops.end()) {
if (block_desc->HasVarRecursive(grad_var_name)) {
Copy link
Member

Choose a reason for hiding this comment

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

In fact, variable in Control operator will be used in nested blocks. It's created in parent block, but used in children block. So it should be find recursively.

// FIXME: Hack code here
auto& ctrl_flow_ops = CtrlFlowOps();
if (ctrl_flow_ops.find(op_desc->Type()) == ctrl_flow_ops.end()) {
// Only computational op need drop input's gradient.
Copy link
Member

Choose a reason for hiding this comment

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

In fact, the backward of Control Operator is not calculating gradient. So no_grad_vars does no sense to Control Operator.

try {
return framework::make_ddim(var->Shape());
auto shape = var->Shape();
if (shape.empty()) {
Copy link
Member

Choose a reason for hiding this comment

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

In which case, the shape is empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The final step of RNN network. Memory's gradient could be empty.

framework::CopyFrom(x_array[offset], dev_ctx.GetPlace(), dev_ctx,
out_tensor);
out_tensor->set_lod(x_array[offset].lod());
} else {
Copy link
Member

Choose a reason for hiding this comment

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

In which case will offset > x_array.size() occur? Why not throw exception here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Final timestep, memory

Copy link
Member

@QiJune QiJune left a comment

Choose a reason for hiding this comment

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

LGTM

@reyoung reyoung merged commit d5e3279 into PaddlePaddle:develop Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants