gather_nd
该OP是 gather
的高维推广,并且支持多轴同时索引。 index
是一个K维度的张量,它可以认为是从 input
中取K-1维张量,每一个元素是一个切片:
显然, 并且输出张量的维度是 index.shape[:-1] + input.shape[index.shape[-1]:]
。
shape为index.shape[:-1] + input.shape[index.shape[-1]:]的Tensor|LoDTensor,数据类型与 一致。
x = fluid.layers.data(name='x', shape=[3, 4, 5], dtype='float32')
index = fluid.layers.data(name='index', shape=[2, 2], dtype='int32')