首页 > 解决方案 > Keras - How to get only one tensor from a batch of tensors?

问题描述

I have a batch of tensors of shape ?,192. Now I want to get any single random tensor from this batch. the resulting tensor should have the shape of 1,192, note that this should be done in Keras. Any idea of how to get this done?

标签: pythonkerasdeep-learning

解决方案


该问题已通过具有 lambda 函数的 tensorflow 操作解决

Var= Lambda(lambda inputs: tf.gather_nd(inputs, [[0]]) )(Var)

推荐阅读