  Contrastive learning has been applied to Human Activity Recognition (HAR)
based on sensor data owing to its ability to achieve performance comparable to
supervised learning with a large amount of unlabeled data and a small amount of
labeled data. The pre-training task for contrastive learning is generally
instance discrimination, which specifies that each instance belongs to a single
class, but this will consider the same class of samples as negative examples.
Such a pre-training task is not conducive to human activity recognition tasks,
which are mainly classification tasks. To address this problem, we follow
SimCLR to propose a new contrastive learning framework that negative selection
by clustering in HAR, which is called ClusterCLHAR. Compared with SimCLR, it
redefines the negative pairs in the contrastive loss function by using
unsupervised clustering methods to generate soft labels that mask other samples
of the same cluster to avoid regarding them as negative samples. We evaluate
ClusterCLHAR on three benchmark datasets, USC-HAD, MotionSense, and UCI-HAR,
using mean F1-score as the evaluation metric. The experiment results show that
it outperforms all the state-of-the-art methods applied to HAR in
self-supervised learning and semi-supervised learning.
