Paddle
Paddle copied to clipboard
动态索引tensor中的一部分
构建网络时生成了序列的表示,其shape为(batch, seq_len, dim),同时生成了一个shape为(batch, seq_len) 的一个binary index,想要依据该binary index 从序列表示中gather 一部分tensor。请问是否可以实现呢?
http://paddlepaddle.org/documentation/docs/zh/1.2/api_cn/layers_cn.html#gather 这是比较接近的一个op 你看能构造这样的输入吗
https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/unittests/test_py_func_op.py#L97 这是个py_func的例子,你可以用Python实现op