mvasil / fashion-compatibility

Learning Type-Aware Embeddings for Fashion Compatibility
BSD 3-Clause "New" or "Revised" License
152 stars 42 forks source link

Loss function for learn similarity (just image embedding) #22

Open huangpen opened 3 years ago

huangpen commented 3 years ago

I believe that you want anchor image feature to embed farther than positive and negative embedding since positive and negative samples are the same clothing type. However, in your code you wrote

disti_p = F.pairwise_distance(general_y, general_z, 2) disti_n1 = F.pairwise_distance(general_y, general_x, 2) disti_n2 = F.pairwise_distance(general_z, general_x, 2) loss_sim_i1 = self.criterion(disti_p, disti_n1, target) loss_sim_i2 = self.criterion(disti_p, disti_n2, target)

where general_x, general_y, general_z are representing anchor, negative, and positive data respectively. I think it should instead be

loss_sim_i1 = self.criterion(disti_n1, disti_p, target) loss_sim_i2 = self.criterion(disti_n2, disti_p, target)

Am I missing something?