如何在张量流中求二维稀疏张量与三维稠密矩阵的点积?

2024-10-03 06:25:14 发布

您现在位置:Python中文网/ 问答频道 /正文

二维稠密张量与三维稠密张量的张量积可以按如下方式进行:

shape=[2,4,3]
dense2d  = tf.constant([[0,1.0,2.0],[0,0,0],[0,0,0]])
dense3d  = tf.placeholder("float", shape=shape)
res = tf.tensordot(dense3d,dense2d,axes=1)
res.set_shape(shape)

我们可以用二维稀疏张量代替它来得到同样的结果吗?如果我们有密码呢

^{pr2}$

而不是dense2d?在

仅供参考,这篇文章与这个github issue有关。我知道tf.sparse_tensor_dense_matmul不支持rank>;2。有解决办法吗?在


Tags: 密码tf方式resfloatplaceholdershapeset