Contrastive-Adaptation-Network-for-Unsupervised-Domain-Adaptation
Contrastive-Adaptation-Network-for-Unsupervised-Domain-Adaptation copied to clipboard
Features normalization computing centers
Thank you for sharing code!
I have a question about the function get_centers that computes the centers of clusters. Did you forget to normalize features before multiply them per mask? Or simply the normalization is in the net forward?
https://github.com/kgl-prml/Contrastive-Adaptation-Network-for-Unsupervised-Domain-Adaptation/blob/bdea238ed343f8919d3ef74fc928ebdb81561008/solver/utils.py#L99
I think that you can see the code normalizing features in clusteing.py :
def cos(self, pointA, pointB, cross):
pointA = F.normalize(pointA, dim=1) #Cosine similarity only cares about direction
pointB = F.normalize(pointB, dim=1)
if not cross:
return 0.5 * (1.0 - torch.sum(pointA * pointB, dim=1))
else:
NA = pointA.size(0)
NB = pointB.size(0)
assert(pointA.size(1) == pointB.size(1))
return 0.5 * (1.0 - torch.matmul(pointA, pointB.transpose(0, 1)))
Hi, I have the same question. It seems that the center is the sum of features instead of mean.
Hi, There are normalize operation, Beacause Cosine similarity only cares about direction!
Hi, There are normalize operation, Beacause Cosine similarity only cares about direction!
Thanks for your reply!