python - 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?
解决方案
该问题已通过具有 lambda 函数的 tensorflow 操作解决
Var= Lambda(lambda inputs: tf.gather_nd(inputs, [[0]]) )(Var)
推荐阅读
- python - Bamboo - Docker image run Error - Connection refused
- django - 在 Django 中创建用户历史 API
- postgresql - 将 postgres JSON 转换为行
- excel - 如何通过范围内的 ID 和日期过滤找到最大值和最小值
- core-data - Previewing ContentView with CoreData
- multithreading - 优化 OpenCL 缓冲区写入?
- pandas - 递归地列出树/有向图中节点的邻居,对于图中的所有节点,一次一个“级别”?
- here-api - Fleet Telematics Waypoints Sequence response time
- java - 在 Scala 中对 Java 列表进行平面映射
- android - 尝试 UnitTest 时,出现 Jacoco 错误。即使它没有使用