TwinGAN icon indicating copy to clipboard operation
TwinGAN copied to clipboard

Cosine Distance

Open Zeros12 opened this issue 5 years ago • 4 comments

Hi, thank you for such a nice piece of work.

In Section 4.4 in your paper, it is mentioned that you have calculated the cosine distance between the flattened embedding. If we have 4 images. i.e. f(x1), f(x1'), and f(x2), f(x2') where f(x1) and f(x1') are the real images and generated images in domain X1 and f(x2) and f(x2') are the real images and generated images in domain X2. Can you please suggest did you calculate the cosine distance between f(x1) and f(x1') or between f(x1) and f(x2') or between f(x1) and f(x2) ?

Thanks in advance.

Zeros12 avatar Jul 11 '19 05:07 Zeros12

Hi, thanks for your encouraging words.

Sorry I am not completely sure which part is confusing to you. The cosine distance between two normalized vectors v1 and v2 is defined as 1 - dot_product(v1, v2).

f is the trained encoder, and will thus be different for each domain. From an image, you can get the embedding by taking the output of f, flatten the vector to make it 1 dimensional, then normalize it so that it's length is 1. You do the same thing to the other input image, and you can compute cosine distance using the equation above.

Hopefully that answers your question

jerryli27 avatar Jul 13 '19 05:07 jerryli27

Thanks for reply.

I am just confused about that did you calculate the cosine distance between the real images from two domains or between the generated images?

Zeros12 avatar Jul 15 '19 07:07 Zeros12

Between the real images.

jerryli27 avatar Jul 17 '19 01:07 jerryli27

Thank you so much.

Zeros12 avatar Jul 17 '19 04:07 Zeros12