Dot product of two vectors in tensorflow

前端 未结 9 1129
悲&欢浪女
悲&欢浪女 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:55

    you can use tf.matmul and tf.transpose

    tf.matmul(x,tf.transpose(y))
    

    or

    tf.matmul(tf.transpose(x),y)
    

    depending on the dimensions of x and y

提交回复
热议问题