sequence_scatter
注解
该OP的输入index,updates必须是LoDTensor。
该OP根据index提供的位置将updates中的信息更新到输出中。
该OP先使用input初始化output,然后通过output[instance_index][index[pos]] += updates[pos]方式,将updates的信息更新到output中,其中instance_idx是pos对应的在batch中第k个样本。
output[i][j]的值取决于能否在index中第i+1个区间中找到对应的数据j,若能找到out[i][j] = input[i][j] + update[m][n],否则 out[i][j] = input[i][j]。
样例:
参数:
input (Variable) - 维度为
的Tensor, 支持的数据类型:float32,float64,int32,int64。
updates (Variable) - 包含updates信息的LoDTensor,lod level和index一致,数据类型与input的数据类型一致。支持的数据类型:float32,float64,int32,int64。
返回:在input的基础上使用updates进行更新后得到的Tensor,它与input有相同的维度和数据类型。
返回类型:Variable
代码示例:
import paddle.fluid as fluid
index = fluid.data( name='index', shape=[12, 1], dtype='int64', lod_level=1)
output = fluid.layers.sequence_scatter(input, index, updates)