【发布时间】:2021-01-11 18:42:53
【问题描述】:
嗨,我真正想要的是,如果我们有矩阵 W 和向量 V,例如:
V=[1,2,3,4]
W=[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]]
我们应该得到结果:
result=[[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
我在网站上找到了这个方法:
V = tf.constant([1,2,4], dtype=tf.float32)
W = tf.constant([[1,2,3,4],[1,2,3,4],[1,2,3,4]], dtype=tf.float32)
tf.multiply(tf.expand_dims(V,1),W)
## produce: [[1,2,3,4],[2,4,6,8],[4,8,12,16]]
这正是我想要的,但是当我在我的模型上实现它时,它还包括导致错误的向量的批量大小
with input shapes: [?,1,297], [?,297,300].
我认为这会产生相同的错误
V = tf.constant([[1,2,4]], dtype=tf.float32)
W = tf.constant([[[1,2,3,4],[1,2,3,4],[1,2,3,4]]], dtype=tf.float32)
tf.multiply(tf.expand_dims(V,1),W)
我想知道从softmax输出向量中获取每个元素并将它们乘以特征张量中每个向量的权重的标准过程是什么
【问题讨论】:
标签: python tensorflow tensor softmax