Skip to main content
. 2024 Feb 11;24(4):1189. doi: 10.3390/s24041189
Algorithm 2 Contrastive Sample Identification (CSI) Task
  • Require: Positive video features V+, Positive text features T+, Negative text features T, Negative video features V

  • Ensure: Binary classification of fused features as matching or mismatching

  •   1: function FindMostSimilarNegativeSample(V+, T, T+)

  •   2:     similaritymax

  •   3:     neg_samplemaxnull

  •   4:     for each t in T do

  •   5:         similaritySimilarity(V+,t)

  •   6:         if similarity>similaritymax then

  •   7:            similaritymaxsimilarity

  •   8:            neg_samplemaxt

  •   9:         end if

  • 10:     end for

  • 11:     return neg_samplemax

  • 12: end function

  • 13: function FuseFeatures(v, t)

  • 14:     tenc AddEncToken(t)                                    ▹ Prepend ‘enc_token’ to text feature

  • 15:     fBERT(tenc,v)            ▹ Input text to BERT and video feature to Cross Attention

  • 16:     return f                                                ▹ Output from BERT corresponding to enc_token

  • 17: end function

  • 18: function ContrastiveSampleIdentification(V+, T+, T, V)

  • 19:     Pmatch[]

  • 20:     Pmismatch[]

  • 21:     neg_textFindMostSimilarNegativeSample(V+,T)

  • 22:     neg_videoFindMostSimilarNegativeSample(T+,V)

  • 23:     fusedmatchFuseFeatures(V+,T+)

  • 24:     fusedmismatch_textFuseFeatures(V+,neg_text)

  • 25:     fusedmismatch_videoFuseFeatures(neg_video,T+)

  • 26:     Append fusedmatch to Pmatch

  • 27:     Append fusedmismatch_text and fusedmismatch_video to Pmismatch

  • 28:     for each fused_feature in PmatchPmismatch do

  • 29:         classificationClassifier(fused_feature)

  • 30:         if fused_feature is in Pmatch then

  • 31:            Expect classification to be 1

  • 32:         else

  • 33:            Expect classification to be 0

  • 34:         end if

  • 35:     end for

  • 36: end function