<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Zero-Shot Learning with Matching Networks for Open-Ended Human Activity Recognition</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Anjana Wijekoon</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nirmalie Wir</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>School of Computing Science and Digital Media, Robert Gordon University</institution>
          ,
          <addr-line>Aberdeen AB10 7GJ, Scotland</addr-line>
          ,
          <country country="UK">UK</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>A real-world solution for Human Activity Recognition (HAR) should cover a variety of activities. However training a model to cover each and every possible activity is not practical. Instead we need a solution that can adapt its learning to unseen activities; referred to as open-ended HAR. Recent advancements in deep learning have increasingly begun to focus on the need to learn from few examples, referred to as k-shot learning and to go beyond this to transfer that learning to situations with unseen classes, referred to as zero-shot learning. The latter is particularly relevant to our research in open-ended HAR; and as yet remains unexplored. This paper presents our preliminary work with Zero-shot Learning (ZSL) with a Matching Network to address openended HAR. A Matching Network has the desirable property of learning with few examples and so is well suited to explorations in ZSL. We evaluate Matching Networks for ZSL with a HAR dataset. We propose the use of a variable length support set at test time to overcome the search for the best support set combination that currently plagues the xed length support set size used by matching nets. Our results show that the variable length approach to be an e ective strategy to maintain accuracy whilst avoiding the combinatorial search for the best class combination to form the support set.</p>
      </abstract>
      <kwd-group>
        <kwd>Zero-shot learning</kwd>
        <kwd>Matching Networks</kwd>
        <kwd>Open-ended HAR</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Activity monitoring with wearable sensors is a popular digital health
intervention incorporated in many health and well-being mobile applications. A study
conducted in 2015 concluded that 58% of smart phone users in US downloaded
health-care tness applications on their mobile, and 47% of those who
downloaded, stopped using them due to the high burden of data entry and loss of
interest [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Current tness applications are restricted only to identifying a few
pre-de ned activities automatically and they rely on user input for other
activities. A sustainable HAR applications should be able to learn new activities
over time with little user calibration. Accordingly researchers have recognised
the need for Open-ended Human Activity Recognition (HAR).
      </p>
      <p>
        An open-ended HAR solution should have the ability to recognise activities
without prior knowledge about them. Existing open-ended HAR methodologies
look at di erent unsupervised activity discovery techniques such as on-line
clustering [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. But these techniques are implemented subject to various assumptions.
For instance motif discovery algorithms for detecting activities depends on
nding patterns in data [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]; whilst the on-line clustering approach used by [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] is
based on the assumption that activities appear only once and not periodically.
Such pre-requisites restrict the deployment of these methodologies in real-time
HAR applications.
      </p>
      <p>
        Ability to incorporate personal traits when expanding beyond ambulatory
activities to exercises and sports improves performance and user acceptance.
Recent work in personalisation with Matching Networks has shown promising
results for personalised HAR [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Matching Network was introduced for k-shot
learning [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] where the network is trained to recognise a new class from just a
small(k) number of examples of that class. K-shot learning is advantageous in
HAR since it minimises the need for extensive data collection and labelling.
Accordingly we explore Matching Networks for open-ended HAR in the context
of Zero-shot Learning (ZSL). In literature ZSL is de ned as recognising new
categories of instances without training examples, by providing a high-level
description of the new categories that relate them to categories previously learned
by the machine [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. In the context of Matching networks we simply de ne ZSL
as classi cation of classes not seen during training.
      </p>
      <p>This paper presents preliminary work on de ning ZSL for the HAR
domain, reporting results with the SelfBACK dataset1. We expose the challenges of
adopting ZSL with matching networks and propose the use of a variable length
support set as a new test approach to perform e cient ZSL. A comparative
study demonstrates the utility of this proposal.</p>
      <p>The rest of this paper is organised as follows: in Section 2, we will formalise
ZSL with Matching Networks in the domain of HAR, and in Section 3 we present
a description of our dataset and experimental design. Results are presented in
Section 4 followed by conclusions in Section 5.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Zero Shot Learning with Matching Networks</title>
      <p>
        Matching Networks can be viewed as an end-to-end neural implementation of
the otherwise static kNN algorithm. The network iteratively learns to match
a given target instance to a small set of instances called a support set [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. An
attention mechanism in the form of a, cosine similarity weighted majority vote,
is used to inform the loss function which is driven by the di erence between the
estimated and actual class distributions (quanti ed using cross entropy). This
ensures that the network eventually learns an embedding that is best placed
1 The SelfBACK project is funded by European Union's H2020 research and
innovation programme under grant agreement No. 689043. More details available:
http://www.selfback.eu. The dataset associated with this paper is publicly
accessible from https://github.com/selfback/activity-recognition
to identify matches between the target and the support set instances. In other
words the network learns to match. Unlike conventional machine learning, here
an instance comprises both the target instance and is its support set.
      </p>
      <p>More formally a matching network predicts label y^ for an example x^ guided
by a support set S. Lets consider a dataset with set of X activity instances
belonging to set of L activity classes. We de ne a support set S as in Equation 1.
Cardinality of the support set is k ntr, where k is the number of instances per
class. ntr is the number of classes in support set and ntr jLj.</p>
      <p>S = f(x; y)jx 2 X ; y 2 Lg
(1)</p>
      <p>The matching net's training set, f(t1; S1); (t2; S2); : : : ; (tN ; SN )g, has N
elements, where each target instance, ti, is a training instance pair, (x; y), and is
never featured in its' support set, Si (i.e. ti 62 Si). A Matching Networks classi er
model, , learns to recognise the activity class, y, for a given target instance, x,
relative to support set, S.</p>
      <p>At deployment, the user records a set of instances, X^, for a set of, L^, activity
classes. We can view this as the user providing a small set of instances for model
calibration. We predict the label, y^, for test activity instance, x^, relative to a
support set, S^.</p>
      <p>
        (x^; S^) ! y^
S^ = f(x; y)jx 2 (X [ X^); y 2 (L [ L^)g
(2)
Accordingly we de ne, S^, as in Equation 2. Cardinality of set S^ is k nte, where
nte is the number of classes in the support set at deployment. With one shot
learning [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], nte is restricted to the size of the training support set, (nte = ntr).
With ZSL this forces the network to select a subset of classes from both training
classes(L) and test classes(L^). This has the undesirable property that the set of
possible combinations, grows exponentially with increasing numbers of unknown
classes at deployment. As a result the support set may not include the class(y^),
which x^ belongs to, resulting in poor performance.
      </p>
      <p>We propose a deployment approach where the number of classes in the
support set size is customisable. Accordingly we introduce condition, nte jLj+jL^j,
which facilitates inclusion of all available classes in the support set. This allows
the classi er to make an informed decision when predicting activity, y^, relative
to the support set.</p>
      <p>Figure 1 illustrates how the typical matching network with xed length
support set are used for k-shot learning as well as ZSL. With ZSL we can see how
the absence of the expected class in the support set can result in a poor
classi cation outcome. One way round this is to try out several class combinations
within the support set (potential for combinatorial explosion). The alternative
is to expand the support size to cover as many as the expected number of classes
at test / deployment time.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Evaluation</title>
      <p>We compare two methodologies below to explore ZSL with Matching networks:</p>
      <sec id="sec-3-1">
        <title>One shot learning</title>
        <p>Test instance</p>
      </sec>
      <sec id="sec-3-2">
        <title>Zero shot learning</title>
        <sec id="sec-3-2-1">
          <title>Test instance</title>
        </sec>
        <sec id="sec-3-2-2">
          <title>Test instance</title>
          <p>
            t
e
S
tr
o
p
p
u
S
h
t
g
n
e
L
d
e
x
i
F
t
e
S
tr
o
p
p
u
S
h
t
g
n
e
L
d
e
x
i
F
t
e
S
tr
o
p
p
u
S
h
t
g
n
e
L
e
l
b
a
ir
a
V
{ the original xed length support sets where, nte = ntr; and
{ the proposed variable length support set where, nte jLj + jL^j
SelfBACK dataset was compiled with a tri-axial accelerometer data streams
belonging to 9 activity classes performed by 50 individuals. Accelerometer was
mounted on the right-hand wrist and each activity was performed for
approximately 3 minutes. Data was recorded in ftime-stamp, x, y, zg format at 100Hz
sampling rate. We use pre-processing steps used by [
            <xref ref-type="bibr" rid="ref7">7</xref>
            ] in this work, that are
supported with evidence of improved accuracy in previous work [
            <xref ref-type="bibr" rid="ref5 ref6">6, 5</xref>
            ].
We follow a disjoint test strategy [
            <xref ref-type="bibr" rid="ref9">9</xref>
            ] when designing the experiment, where
test classes will only include classes not seen during training. We evaluate ZSL
with eight training classes (jLj = 8) and one test class (jL^j = 1). Accordingly
we conduct nine experiments so that each class appears once as the test class.
For instance Ejogging will refer to experiment where jogging activity is the test
class and other eight classes are in training. In which case we are testing the
models ability to make predictions about the unseen jogging class. The two test
approaches compared in the evaluation are:
Fixed length support sets: where ntr = nte = 8, we create several
combinations of classes using a random sampling (without replacement) to select
the 8 classes for the support set at test time from the set of 9 classes.
Accordingly we evaluate 9 combinations for each experiment. Note that one
combination in each experiment does not include the expected class, of the
test instance, in which case, we assign test accuracy to be zero percent.
Variable length support sets: is introduced as having,ntr = 8 and nte = 9,
to help mitigate situations (in the case of random selection with xed length
support set) where the expected test class may not be sampled in the test
support set. Speci cally we evaluate the condition, nte = jLj + jL^j, where we
include all nine classes in the test support set.
          </p>
          <p>
            We use the matching network architecture in [
            <xref ref-type="bibr" rid="ref7">7</xref>
            ] to generate the embedding
functions. In order to enforce personalisation, we always select support set data
from the same user. We use k = 5 through all experiments. We use the rst
ve instances of each test class to form the support set instances (simulating
a scenario where the user provide few calibration examples for a class not seen
during training), and rest as test instances. We perform a hold-out validation
with all our experiments by selecting 8 random users as test set and rest as
training set. We use accuracy as performance measure.
4
          </p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Results and Discussion</title>
      <p>For xed length support sets, we evaluated 81 possible combinations of test
support sets when one class was considered as not part of training. A summary of
results (minimum, maximum, average and median accuracies) from these
combinations appear in Table 1 (columns under xed length support set). Minimum
accuracy obtained with a test support set combination is always zero; this is
when the support set combination does not contain the expected test class which
at test time will be the calibration data. Note that random guessing of a class
would achieve only 11% accuracy (as we have 9 classes). These results emphasise
the importance of considering all possible classes in test support set. We present
median of all combinations to show how average is a ected by having an
experiment with zero accuracy. We observe some interesting interactions between
the target instances actual class and class combinations in its support set. For
instance with Ejogging, accuracy was heavily penalised when class downstairs is
in the support set. Similarly behaviour was observed with class Eupstairs when
walk-slow activity is included in the test support set. These results provide
useful insights as to the e ect of di erent activities have on each other due to their
inter-class similarities at an embedding level.</p>
      <p>
        Results with ZSL using a Variable length support set is presented in the
last column of Table 1. We can observe that recognition of new activities (i.e.
not seen during training but with some calibration data at test time) has in
places signi cantly higher accuracy and surpass accuracies with the xed length
approach (e.g. Jogging and Sitting). With others; such as downstairs, walk fast
and upstairs yield accuracies under 50%. Looking at classi cation accuracies
from previous work on this data set [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], we identify these classes are challenging
to classify even with a traditional classi cation algorithm. However they show
comparable or better performance to average accuracies obtained with xed
length approach, hence we can conclude that variable length is still advantages
over xed length approach. Overall recognition of Walk fast proved to most
challenging when compared to the average of xed length approach. It is possible
that the inter-class similarity relationships play a role here.
5
      </p>
    </sec>
    <sec id="sec-5">
      <title>Conclusions</title>
      <p>We explore two problems that ZSL with Matching Networks pose: the problem
of nding the best class combinations with a xed support set size at test time;
and related to that the situation when the expected class may not be in the
support set at test time. There is an optimum class combination that helps to
classify unseen instances; however searching the space of possible combinations
is a combinatorial problem. We resolve this by introducing a new test approach
with variable length test support set. We experiment with a disjoint test set
and yield comparatively better classi cation performance with variable length
approach for several activities recognitions classes. In future we will look at
how inter-class relationships in a support set might impact performance when
applying ZSL. Additionally we will extend our evaluations to overlap test sets
and other HAR data sets to further validate this approach.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1. Berlin, E.,
          <string-name>
            <surname>Van Laerhoven</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>Detecting leisure activities with dense motif discovery</article-title>
          .
          <source>In: Proceedings of the 2012 ACM Conference on Ubiquitous Computing</source>
          . pp.
          <volume>250</volume>
          {
          <fpage>259</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Gjoreski</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Roggen</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Unsupervised online activity discovery using temporal behaviour assumption</article-title>
          .
          <source>In: Proceedings of the 2017 ACM International Symposium on Wearable Computers</source>
          . pp.
          <volume>42</volume>
          {
          <fpage>49</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Krebs</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Duncan</surname>
          </string-name>
          , D.T.:
          <article-title>Health app use among us mobile phone owners: a national survey</article-title>
          .
          <source>JMIR mHealth and uHealth 3</source>
          (
          <issue>4</issue>
          ) (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Romera-Paredes</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Torr</surname>
            ,
            <given-names>P.:</given-names>
          </string-name>
          <article-title>An embarrassingly simple approach to zero-shot learning</article-title>
          .
          <source>In: International Conference on Machine Learning</source>
          . pp.
          <volume>2152</volume>
          {
          <issue>2161</issue>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Sani</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Massie</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wiratunga</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cooper</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>Learning deep and shallow features for human activity recognition</article-title>
          .
          <source>In: International Conference on Knowledge Science, Engineering and Management</source>
          . pp.
          <volume>469</volume>
          {
          <fpage>482</fpage>
          . Springer (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Sani</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wiratunga</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Massie</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cooper</surname>
          </string-name>
          , K.:
          <article-title>knn sampling for personalised human activity recognition</article-title>
          .
          <source>In: International Conference on Case-Based Reasoning</source>
          . pp.
          <volume>330</volume>
          {
          <fpage>344</fpage>
          . Springer (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Sani</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wiratunga</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Massie</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cooper</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>Personalised human activity recognition using matching networks</article-title>
          .
          <source>In: International Conference on Case-Based Reasoning</source>
          . Springer (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Vinyals</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Blundell</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lillicrap</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wierstra</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          , et al.:
          <article-title>Matching networks for one shot learning</article-title>
          .
          <source>In: Advances in Neural Information Processing Systems</source>
          . pp.
          <volume>3630</volume>
          {
          <issue>3638</issue>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Xian</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schiele</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Akata</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          :
          <article-title>Zero-shot learning-the good, the bad and the ugly</article-title>
          .
          <source>In: 30th IEEE Conference on Computer Vision and Pattern Recognition</source>
          . pp.
          <volume>3077</volume>
          {
          <fpage>3086</fpage>
          . IEEE Computer Society (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>