Only the diagonal elements of the similarity matrix have a target value of 1
def generate_gt_v1(labels:List[int]):
""" The lables generation process in MMAction2
Args:
labels (List[int]): each element is a class id of a sample.
"""
gt = np.arange(len(labels))
return gt
1.2 Loss Function
So, MMAction2 uses Cross-entropy as the default similarity loss function.
if samples x_i and x_j have the same label then gt[i,j]=1 else gt[i,j]=0
def generate_gt_v2(labels:List[int]):
""" The lables generation process in ActionCLIP
Args:
labels (List[int]): each element is a class id of a sample.
"""
num = len(labels)
gt = np.zeros(shape=(num,num))
for i in range(num):
for j in range(num):
if labels[j] == labels[i]:
gt[i,j] = 1
return gt
2.2 Loss Function
So, ActionCLIP uses KL Loss as the default similarity loss function.
Branch
main branch (1.x version, such as
v1.0.0
, ordev-1.x
branch)Prerequisite
Environment
Describe the bug
1. Implementation of the MMAction2
1.1 Labels Generation
link: https://github.com/open-mmlab/mmaction2/blob/4d6c93474730cad2f25e51109adcf96824efc7a3/projects/actionclip/models/actionclip.py#L162-L163
If i==j then gt[i,j]=1 else gt[i,j]=0
Only the diagonal elements of the similarity matrix have a target value of 1
1.2 Loss Function
So, MMAction2 uses Cross-entropy as the default similarity loss function.
link: https://github.com/open-mmlab/mmaction2/blob/4d6c93474730cad2f25e51109adcf96824efc7a3/projects/actionclip/models/actionclip.py#L165-L166
2. Implementation of the code released by the ActionCLIP authors
2.1 Labels Generation
link: https://github.com/sallymmx/ActionCLIP/blob/31c34df17dce917d67127b7fb155922c4744f680/utils/tools.py#L7
if samples x_i and x_j have the same label then gt[i,j]=1 else gt[i,j]=0
2.2 Loss Function
So, ActionCLIP uses KL Loss as the default similarity loss function.
link: https://github.com/sallymmx/ActionCLIP/blob/31c34df17dce917d67127b7fb155922c4744f680/train.py#L177
Does it have better performance or higher efficiency for the current implementation in MMAction2? Looking forward to the answer~
Reproduces the problem - code sample
No response
Reproduces the problem - command or script
No response
Reproduces the problem - error message
No response
Additional information
No response