提交 cc82ff0d 编写于 作者: Y Yibing Liu

Merge branch 'develop' of upstream into add_lstmp_doc

...@@ -139,10 +139,8 @@ class PoolGradKernel : public framework::OpKernel<T> { ...@@ -139,10 +139,8 @@ class PoolGradKernel : public framework::OpKernel<T> {
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
if (in_x_grad) { if (in_x_grad) {
in_x_grad->mutable_data<T>(context.GetPlace()); in_x_grad->mutable_data<T>(context.GetPlace());
auto temp = framework::EigenVector<T>::Flatten(*in_x_grad); paddle::operators::math::SetConstant<DeviceContext, T> set_constant;
temp.device( set_constant(dev_ctx, in_x_grad, 0.0);
*context.template device_context<DeviceContext>().eigen_device()) =
temp.constant(static_cast<T>(0));
switch (ksize.size()) { switch (ksize.size()) {
case 2: { case 2: {
......
...@@ -225,7 +225,7 @@ class DistributeTranspiler: ...@@ -225,7 +225,7 @@ class DistributeTranspiler:
if len(splited_vars) <= 1: if len(splited_vars) <= 1:
continue continue
orig_var = program.global_block().vars[varname] orig_var = program.global_block().vars[varname]
if orig_var == core.VarDesc.VarType.SELECTED_ROWS: if orig_var.type == core.VarDesc.VarType.SELECTED_ROWS:
height_sections = [] height_sections = []
for v in splited_vars: for v in splited_vars:
height_sections.append(v.shape[0]) height_sections.append(v.shape[0])
...@@ -234,7 +234,7 @@ class DistributeTranspiler: ...@@ -234,7 +234,7 @@ class DistributeTranspiler:
inputs={"X": orig_var}, inputs={"X": orig_var},
outputs={"Out": splited_vars}, outputs={"Out": splited_vars},
attrs={"height_sections": height_sections}) attrs={"height_sections": height_sections})
elif orig_var == core.VarDesc.VarType.LOD_TENSOR: elif orig_var.type == core.VarDesc.VarType.LOD_TENSOR:
sections = [] sections = []
for v in splited_vars: for v in splited_vars:
sections.append(v.shape[0]) sections.append(v.shape[0])
......
...@@ -118,12 +118,13 @@ def seq_to_seq_net(): ...@@ -118,12 +118,13 @@ def seq_to_seq_net():
src_forward, src_backward = bi_lstm_encoder( src_forward, src_backward = bi_lstm_encoder(
input_seq=src_embedding, hidden_size=encoder_size) input_seq=src_embedding, hidden_size=encoder_size)
encoded_vector = fluid.layers.concat( src_forward_last = fluid.layers.sequence_last_step(input=src_forward)
input=[src_forward, src_backward], axis=1) src_backward_first = fluid.layers.sequence_first_step(input=src_backward)
enc_vec_last = fluid.layers.sequence_last_step(input=encoded_vector) encoded_vector = fluid.layers.concat(
input=[src_forward_last, src_backward_first], axis=1)
decoder_boot = fluid.layers.fc(input=enc_vec_last, decoder_boot = fluid.layers.fc(input=encoded_vector,
size=decoder_size, size=decoder_size,
bias_attr=False, bias_attr=False,
act='tanh') act='tanh')
...@@ -137,7 +138,7 @@ def seq_to_seq_net(): ...@@ -137,7 +138,7 @@ def seq_to_seq_net():
dtype='float32') dtype='float32')
prediction = lstm_decoder_without_attention(trg_embedding, decoder_boot, prediction = lstm_decoder_without_attention(trg_embedding, decoder_boot,
enc_vec_last, decoder_size) encoded_vector, decoder_size)
label = fluid.layers.data( label = fluid.layers.data(
name='label_sequence', shape=[1], dtype='int64', lod_level=1) name='label_sequence', shape=[1], dtype='int64', lod_level=1)
cost = fluid.layers.cross_entropy(input=prediction, label=label) cost = fluid.layers.cross_entropy(input=prediction, label=label)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册