CKA-Centered-Kernel-Alignment
CKA-Centered-Kernel-Alignment copied to clipboard
size issue
hi guys, Is it true that the CKA could only calculate matrix with 2 size? one for BS, one for another arbitrary one? if so, it seems not suitable to compare among pictures. looking for answer and many thanks
I am not sure if I understood the question. I apologize if I get it wrong. CKA will compare 2 Symmetric Positive Semi-Definite Matrices of Size KxK each. I didn't quite get the part where you refer to comparison between pictures.
I am not sure if I understood the question. I apologize if I get it wrong. CKA will compare 2 Symmetric Positive Semi-Definite Matrices of Size KxK each. I didn't quite get the part where you refer to comparison between pictures.
Thanks for your reply. Let's assume the output of a layer is A with size (BS, C, K, K). The function of kernal_CKA(A, A) turns to be wrong. So I guess it could only deal with matrix of size 2. I suppose this is also the reason the author takes the average of output of (1000,16,16,64) in axis 1 and 2, and thereafter get output of size (1000, 64) in line [25]
Yes, it can only deal with matrices and not tensors. If I may offer a suggestion/guess, I think what you want to do is to take the output of layer with size (BS,C,K,K) and convert it to X.shape = (BS,CKK). Then compute S_1 = XX.T, this will yield a BS x BS sized matrix. You can repeat this process for another layer Y => (BS, C ,K, K)-> (BS,CKK) and compute S_2 = YY.T and compute CKA(S_1,S_2). This is roughly how I do it.
Many thanks dude! I do appreciate your help!
Glad to help.