Dear Mentor,

In the Week 4 Assignment: Art_Generation_with_Neural_Style_Transfer, section 4.2.1 - Style Matrix.

There is one statement about Gram Matrix:

G[i][j] compares how similar v[i] is to v[j]:

If they are highly similar, you would expect them to have a large dot product, and thus for G[i][j] to be large.

**Calculation 1:**

if v[i] = [5,5], v[j] = [5,5].T, the dot product of both = 50

**Calculation 2:**

if v[i] = [5,5], v[j] = [10,10].T, the dot product of both = 100

In the Calculation 2, v[i] and v[j] are not highly similar, but also have a large dot product.

Could you please guide me to understand the statement?

Thank you.

1 Like

What they mean by â€śsimilarâ€ť here is correlation. And weâ€™re talking about vectors, so correlation means vectors pointing in close to the same direction, which is what maximizes the dot product. So (5,5) and (10,10) are very similar, because they point in exactly the same direction, right? Independent of the magnitudes of the two vectors, the dot product is maximized when they point in the same direction. Notice that the dot product will be zero if they are perpendicular and negative if they point in opposite directions.

1 Like

Dear Mr Paul Mielke,

Thank you so much for your guidance.

The other way to make this clear is to remember that an alternative way to compute the dot product of two vectors is:

v \cdot w = ||v|| * ||w|| * cos(\theta)

where \theta is the angle between the two vectors if you position them both at the origin. With that formulation, the behavior of the dot product that I described above is really clear because:

cos(0) = 1

cos(\frac{\pi}{2}) = 0

cos(\pi) = -1

1 Like