- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一些稀疏索引:
[[0 0]
[0 1]
[1 0]
[1 1]
[1 2]
[2 0]]
每个指标对应的值为:
[[0.1 0.2 0.3]
[0.4 0.5 0.6]
[0.7 0.8 0.9]
[1.0 1.1 1.2]
[1.3 1.4 1.5]
[1.6 1.7 1.8]]
如何在tensorflow中将6x3值张量转换为3x3x3稠密张量? indices 中未指定的索引值为零向量 [0. 0. 0.]。稠密张量就是这样:
[[[0.1 0.2 0.3]
[0.4 0.5 0.6]
[0.0 0.0 0.0]]
[[0.7 0.8 0.9]
[1.0 1.1 1.2]
[1.3 1.4 1.5]]
[[1.6 1.7 1.8]
[0.0 0.0 0.0]
[0.0 0.0 0.0]]]
最佳答案
你可以用 tf.scatter_nd
做到这一点:
import tensorflow as tf
with tf.Graph().as_default(), tf.Session() as sess:
indices = tf.constant(
[[0, 0],
[0, 1],
[1, 0],
[1, 1],
[1, 2],
[2, 0]])
values = tf.constant(
[[0.1, 0.2, 0.3],
[0.4, 0.5, 0.6],
[0.7, 0.8, 0.9],
[1.0, 1.1, 1.2],
[1.3, 1.4, 1.5],
[1.6, 1.7, 1.8]])
out = tf.scatter_nd(indices, values, [3, 3, 3])
print(sess.run(out))
输出:
[[[0.1 0.2 0.3]
[0.4 0.5 0.6]
[0. 0. 0. ]]
[[0.7 0.8 0.9]
[1. 1.1 1.2]
[1.3 1.4 1.5]]
[[1.6 1.7 1.8]
[0. 0. 0. ]
[0. 0. 0. ]]]
关于python - 具有矢量值的 Tensorflow 稀疏张量到密集张量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53644034/
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 5 个月前关
我正在尝试使用摄像机跟踪多个人。我不想使用 blob 分割技术。我想做什么: 执行背景减法以获得隔离人们运动的掩码。 在这些区域执行基于网格的光流 -我最好的选择是什么? 我正在努力实现。我已经尝试过
OpenCV 有 very good documentation on generating SIFT descriptors ,但这是“弱 SIFT”的一个版本,其中关键点由原始 Lowe algo
我有一个 cholmod_dense 数据结构: cholmod_dense* ex = cholmod_l_solve(CHOLMOD_A, L, B, &com); 我想提取这些值并将它们复制到另
这是先前发布的关于在 python 中使用 OpenCVs 密集筛选实现的问题的后续问题 (OpenCV-Python dense SIFT)。 使用建议的代码进行密集筛选 dense=cv2
我是计算机视觉的新手。我正在学习 Dense SIFT 和 HOG。对于密集 SIFT,算法只是将每个点视为一个有趣的点并计算其梯度向量。 HOG 是另一种用梯度向量描述图像的方法。 我认为 Dens
我正在尝试使用 openCV-python 2.4 计算密集 SIFT import cv2 def gen_sift_features(gray, step_size, gamma): de
我正在使用 OpenCV 实现词袋图像分类器。最初我测试了在 SURF 关键点中提取的 SURF 描述符。我听说 Dense SIFT(或 PHOW)描述符更适合我的目的,所以我也尝试了它们。 令我惊
我有一个密集的 Ax=b 类型的方程组要在我的 C++ 程序中求解,我希望在 boost 中使用 UBLAS 来实现该解决方案。在其他一些问题中,我发现人们正在使用扩展 LAPACK,但不幸的是,它似
我目前有一台配备 Opteron 275 (2.2Ghz)(双核 CPU)和 4GB RAM 以及速度非常快的硬盘的机器。我发现即使是使用 C++ 模板(想想 boost 等)编译一些简单的项目时,我
我是一名优秀的程序员,十分优秀!