-
Notifications
You must be signed in to change notification settings - Fork 5.7k
While op forward for sentimental analysis #6140
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
While op forward for sentimental analysis #6140
Conversation
A v2 API like data feeder for book demos. We can feed data directly from reader.
…op_sentiment_analysis
…op_sentiment_analysis
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') |
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.
size = [len(self.word_dict), 32]
c00349c
to
6aae3ad
Compare
6aae3ad
to
bf38d85
Compare
paddle/framework/backward.cc
Outdated
return false; | ||
if (ctrl_flow_ops.find(ops[op_index]->Type()) != | ||
ctrl_flow_ops.end()) { | ||
if (block_desc->HasVarRecursive(grad_var_name)) { |
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.
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. |
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.
In fact, the backward of Control Operator is not calculating gradient. So no_grad_vars
does no sense to Control Operator.
@@ -466,7 +466,12 @@ DDim CompileTimeInferShapeContext::GetDim(const std::string &name) const { | |||
auto var = block_.FindVarRecursive(name); | |||
PADDLE_ENFORCE(var != nullptr, "Cannot find variable %s", name); | |||
try { | |||
return framework::make_ddim(var->Shape()); | |||
auto shape = var->Shape(); | |||
if (shape.empty()) { |
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.
In which case, the shape is empty?
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.
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 { |
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.
In which case will offset > x_array.size()
occur? Why not throw exception here?
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.
Final timestep, memory
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 #6139
Also, Fix #6134, Fix #6135
Base on PR #6102