简体   繁体   English

Keras - 如何从一批张量中只获得一个张量?

[英]Keras - How to get only one tensor from a batch of tensors?

I have a batch of tensors of shape ?,192 .我有一批形状为?,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.结果张量的形状应该是1,192 ,注意这应该在 Keras 中完成。 Any idea of how to get this done?知道如何完成这项工作吗?

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError: Merge 只能在张量列表上调用,而不是 keras 中的单个张量 - TypeError: Merge can only be called on a list of tensors, not a single tensor in keras 将张量元组传递给多个损失函数时,Tensorflow/keras 仅使用.fit 传递元组中的一个张量 - Tensorflow/keras when passing tuple of tensors to multiple loss functions, only one tensor in tuple is being passed using .fit Keras:如何仅从张量中提取某些层 - Keras: How to extract only certain layers from a tensor 如何在Keras中获得张量值? - How to get a tensor value in Keras? ValueError:在张量列表上使用 torch.Tensor 时,只能将一个元素张量转换为 Python 标量 - ValueError: only one element tensors can be converted to Python scalars when using torch.Tensor on list of tensors PyTorch DataLoader 将批次作为列表返回,批次作为唯一条目。 如何从我的 DataLoader 获取张量的最佳方式 - PyTorch DataLoader returns the batch as a list with the batch as the only entry. How is the best way to get a tensor from my DataLoader 你如何获得稀疏张量中使用的张量的名称? - How do you get the names of tensors used in a sparse tensor? 如何有条件地从 GPU 上的 PyTorch 中的其他两个张量构造一个张量? - How to conditionally construct a tensor from two other tensors in PyTorch on the GPU? 如何从更大的 pytorch 张量中提取张量到 numpy arrays 或列表 - How to extract tensors to numpy arrays or lists from a larger pytorch tensor 如何在 PyTorch 中训练张量的张量 - How to train a tensor of tensors in PyTorch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM