Vector dot product is widely used in machine learning. In this tutorial, we will introduce it for machine learning beginners.
What is vector dot product?
Given two vectors A and B, the dot product between them are defined as:
We can find the result of two vector dot product is a scalar.
The difference between vector dot product and element-wise multiplication
Vector dot product is different from element-wise multiplication, the element-wise multiplication (product) can be defined as:
Understand Element-wise Multiplication Between Two Vector – Machine Learning Tutorial
From above, we can find:
dot product(A, B) = sum(element-wise multiplication(A, B))
How to calculate the vector dot product?
In tensorflow:
We can use tf.tensordot() function to compute.
In numpy:
We can use numpy.dot() to compute.
Calculate Dot Product of Two Vectors in Numpy for Beginners – Numpy Tutorial