Skip to content

Add GRU Operator#5255

Merged
guoshengCS merged 14 commits intoPaddlePaddle:developfrom
guoshengCS:add-GRUOp-dev
Nov 6, 2017
Merged

Add GRU Operator#5255
guoshengCS merged 14 commits intoPaddlePaddle:developfrom
guoshengCS:add-GRUOp-dev

Conversation

@guoshengCS
Copy link
Contributor

Resolves #5254
Rewrite GatedRecurrentLayer in the new framework. Some code styles haven't formatted.

@guoshengCS guoshengCS changed the title Add gru op dev Oct 31, 2017
Copy link
Contributor

@qingqing01 qingqing01 left a comment

Choose a reason for hiding this comment

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

LGTM.

"(string, default sigmoid) "
"The activation type used in update gate and reset gate.")
.SetDefault("sigmoid");
AddAttr<bool>("is_reverse",
Copy link
Contributor

@qingqing01 qingqing01 Nov 1, 2017

Choose a reason for hiding this comment

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

gate_activation -> gateActivation
is_reverse -> isReverse

ctx->SetOutputDim("BatchHidden", {input_dims[0], frame_size});
ctx->SetOutputDim("Hidden", {input_dims[0], frame_size});
// ctx->ShareLoD("Input", "Gate");
// ctx->ShareLoD("Input", "ResetHiddenPrev");
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these lines.

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.

GRUOpMaker(framework::OpProto* proto, framework::OpAttrChecker* op_checker)
: OpProtoAndCheckerMaker(proto, op_checker) {
AddInput("Input",
"(LoDTensor) The first input is a LodTensor, which support "
Copy link
Contributor

Choose a reason for hiding this comment

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

support -> supports

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.

// } else {
// PADDLE_THROW("Do not support activation type.");
// }
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

remove these lines.

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 relu(x):
return np.maximum(x, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these functions be imported from test_lstm_op.py ?

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.

return batch_gate, batch_reset_hidden_prev, hidden

def set_data(self):
lod = [[0, 2, 6, 9]]
Copy link
Contributor

Choose a reason for hiding this comment

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

lod = [[0, 2, 6, 9]] -> lod = [[0, 2, 6, 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.

qingqing01
qingqing01 previously approved these changes Nov 6, 2017
Copy link
Contributor

@qingqing01 qingqing01 left a comment

Choose a reason for hiding this comment

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

I approve this PR. the code style still needs to update later. And please add the TODO description before this PR is merged.

@guoshengCS guoshengCS merged commit 1d7954f into PaddlePaddle:develop Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants