Dot product of two vectors in tensorflow

前端 未结 9 1172
悲&欢浪女
悲&欢浪女 2021-01-01 12:36

I was wondering if there is an easy way to calculate the dot product of two vectors (i.e. 1-d tensors) and return a scalar value in tensorflow.

Given two vectors X=(

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 12:50

    In addition to tf.reduce_sum(tf.multiply(x, y)), you can also do tf.matmul(x, tf.reshape(y, [-1, 1])).

提交回复
热议问题