【发布时间】:2018-03-13 14:30:40
【问题描述】:
假设我有这两个张量:
-
valueMatrix,形如(?, 3),其中?是批量大小 -
indexMatrix,形如(?, 1)
我想在indexMatrix 中包含的索引处从valueMatrix 检索值。
示例(伪代码):
valueMatrix = [[7,15,5],[4,6,8]] -- shape=(2,3) -- type=float
indexMatrix = [[1],[0]] -- shape = (2,1) -- type=int
我想从这个例子中做类似的事情:
valueMatrix[indexMatrix] --> returns --> [[15],[4]]
比起其他后端,我更喜欢 Tensorflow,但答案必须与使用 Lambda 层或其他适合任务的层的 Keras 模型兼容。
【问题讨论】:
标签: python-3.x tensorflow keras slice tensor