Skip to content

Conversation

@luotao1
Copy link
Contributor

@luotao1 luotao1 commented Sep 19, 2017

solve part1 of #4186
complete seq_sum_pool

For a mini-batch of 3 variable lengths sentences, containing 2, 3, and 2 words:
X = [[1, 3], [2, 4, 6], [5, 1]],
Copy link
Contributor

Choose a reason for hiding this comment

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

换成:containing 2, 3, and 2 time-steps?

X换成[7, M, N]的float tensor? 例子更通用些

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

out_e.device(place) = in_e.sum(Eigen::array<int, 1>({{0}}));
break;
default:
LOG(FATAL) << "unsupported pooling strategy";
Copy link
Contributor

Choose a reason for hiding this comment

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

不要使用LOG(FATAL), 用PADDLE_THROW:

PADDLE_THROW("unsupported pooling strategy");
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

in_g_e.device(place) = (out_g_e).broadcast(bcast);
break;
default:
LOG(FATAL) << "unsupported pooling strategy";
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

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

AddInput("X", "Input of SequenceAvgPoolOp.");
AddOutput("Out", "The output of SequenceAvgPoolOp.");
AddInput("X",
"A float LoDTensor, the variable-length input of SequencePoolOp");
Copy link
Contributor

Choose a reason for hiding this comment

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

remove float

"A float LoDTensor, the variable-length input of SequencePoolOp");
AddOutput(
"Out",
"A float LoDTensor, the variable-length output of SequencePoolOp.");
Copy link
Contributor

Choose a reason for hiding this comment

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

remove float

More detailed comments will be added later.
SequencePoolOp pools features of all time-steps of each instance.
For a mini-batch of 3 variable lengths sentences, containing 2, 3, and 2 time-steps:
Copy link
Contributor

Choose a reason for hiding this comment

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

variable-length sentences

For a mini-batch of 3 variable lengths sentences, containing 2, 3, and 2 time-steps:
Assume X is a [7,M,N] float LoDTensor, and X->lod()[0] = [0, 2, 5, 7].
Copy link
Contributor

Choose a reason for hiding this comment

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

and X->lod()[0] = [0, 2, 5, 7], 7 = 2 +3 + 2

@luotao1
Copy link
Contributor Author

luotao1 commented Sep 25, 2017

Thx @qingqing01 . I will refine doc in next PR.

@luotao1 luotao1 merged commit 01bec25 into PaddlePaddle:develop Sep 25, 2017
@luotao1 luotao1 deleted the seq_pool branch September 25, 2017 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants