Input: Support set
, Query sample xq
|
Output: Similarity score Score
|
1:
size of S ⊳ Get the size of support set S
|
2:
⊳ Initialize total weight W
|
3:
⊳ Set hyperparameter θ
|
4:
⊳ Initialize prototype vector Xproto
|
5: if
then ⊳ If support set contains more than one sample |
6: for
to
n
do ⊳ Loop over each sample in the support set |
7:
⊳ Compute Euclidean distance Di
|
8:
⊳ Calculate total weight W
|
9: end for
|
10: for
to
n
do ⊳ Loop over each sample in the support set again |
11:
⊳ Compute weight wi
|
12:
⊳ Update prototype vector Xproto
|
13: end for
|
14:
⊳ Calculate similarity score |
15: else ⊳ If support set contains only one sample |
16:
⊳ Calculate similarity score for single sample |
17: end if
|