<!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>Using Triplet Loss for bird species recognition on BirdCLEF 2020</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Thailsson Clementino</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Juan G. Colonna</string-name>
          <email>juancolonnag@icomp.ufam.edu.br</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Computing (Icomp), Federal University of Amazonas (UFAM)</institution>
          ,
          <addr-line>Av. General Rodrigo Octavio 6200, Manaus, Amazonas 69077-000</addr-line>
          ,
          <country country="BR">Brazil</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper presents the approach used in the BirdCLEF 2020 Competition. The objective of the competition is to try to recognize bird species through its sings and calls among 960 species in soundscapes. We use a MultiScale CNN + Triplet Loss to learn the melspectrogram characteristics that di erentiate the species from each other. The CNN create a 128-D embedding used to classify the species. The approach achieves third place on the competition with c-mAP of 0.009752 and r-mAP of 0.008. We also present some changes on train parameters done after the competition that achieve our best evaluation with c-mAP 0.062877 and r-mAP of 0.108.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        against embeddings of new samples using a similarity by distance calculation.
The Triplet Loss helps to learn which features, represented by the embedding
vectors, di erentiate samples of di erent species. Related works that make use
of Siamese Neural Networks have been applied in di erent contexts [
        <xref ref-type="bibr" rid="ref13 ref15 ref8">8, 15, 13</xref>
        ],
and also in the context of audio recognition [
        <xref ref-type="bibr" rid="ref11 ref14 ref4">4, 11, 14</xref>
        ]. After reviewing the
related works, we decided to adopt an approach in which we feed the Neural
Network with Mel-spectrograms to generate a unique feature representation of
each species call.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Preprocessing</title>
      <p>As the competition task is to recognize species in every 5 seconds of audio in a
recording, the rst preprocessing was to take all the recordings contained in the
training set and split them into ve-second chunks. There were some recordings
in the training set with less than ve seconds long, in these cases, the records
were padded with copies of themselves until they achieved ve seconds. After
this stage, we obtained a total of 623.981 segments.</p>
      <p>
        Similarly to [
        <xref ref-type="bibr" rid="ref11 ref4 ref9">11, 4, 9</xref>
        ], we opted for a visual approach to model input, using
Mel-scale spectrograms taken from each chunk of audio, as mentioned above.
Furthermore, were also extracted the harmonic and percussive components from
Mel-spectrograms [
        <xref ref-type="bibr" rid="ref14 ref3">3, 14</xref>
        ], once di erent species can has a call more expressive in
one of its components. Figure 1 shows an input example of ve seconds audio
belonging to the species Alder ycatcher. Due to the high computational demands
of preprocessing, we decided to perform a sub sampling in which 70 thousand
spectrograms were separated for training and 20 thousand for validation.
      </p>
      <p>
        All preprocessing steps were carried out with two Python Libraries for audio
processing: PyDub [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] and LIBROSA [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Table 1 shows the parameters used to
extract the Mel-spectrograms.
      </p>
    </sec>
    <sec id="sec-3">
      <title>Approach</title>
      <p>
        Model
Our approach was inspired on [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. Our key idea is to use a Siamese Convolutional
Neural Network to extract features from Mel-spectrograms that can be arranged
in a Euclidean space of n dimensions represented by an embedding vector. We
tested two di erent CNN architectures based on [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. In the rst one, we reduce
the number of Multiscale analysis modules from 4 to 2. In the second one, we
keep the principal backbone architecture without the Dropouts layers between
the two nal dense layers. These adjustments were made empirically, based on
test experiments. The table 2 shows the two implemented CNNs architectures.
Both of them have inputs with shape 40x200x3, representing the three
Melspectrogram with shapes 40x200 mentioned above. All convolutional layers use
Relu as the activation function.
      </p>
      <p>
        The Siamese network with triplet loss aims to generate close embedding
vectors when the inputs belong to the same species and, at the same time, keep
them away from vectors representing other species, considering a Euclidean
vector space [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. In this way, we hope that the new vector representation would
make the classes more easily separable, therefore, easier to classify using a
standard classi er such as kNN (k-Nearest Neighbors).
      </p>
      <p>To achieve faster training convergence, we select the semi-hard triplets, which
are the triplets composed by a negative sample more distant than the positive
sample from the anchor sample. However, this distance lies inside a prede ned
margin . Thus, with this loss function the lower the di erence between positive
and negative distances, the greater is the Loss. Equation 1 shows the loss function
we want to minimize, where f (x) is the embedding vector generated by the
Siamese Network for the input sample x. For the i -th triplet xia represent the
anchor, xip a positive sample, and xin a negative sample.</p>
      <p>N
L = X kf (xia)
i
f (xip)k22
kf (xia)
f (xin)k22 +
+
(1)</p>
      <p>Once we convert all Mel-spectrograms into embeddings vectors, we can use
them to classify each species. In our rst submission, we chose a kNN classi er
with Euclidean distance and, in our other submissions, a Multilayer Perceptron
(MLP) neural network. The MLP architecture has an input layer, a hidden
dense layer with 256 neurons and an output layer with softmax activation and
960 neurons, equivalent to the number of species we wish to recognize.
We tried various combinations of hyperparameters until we reached our results.
Table 4 shows the con guration used in each submission trial. The MLP was
always trained with 200 epochs, batch size of 256 and learning rate equal to
0.001.
The test data has 153 soundscapes of 10 minutes each, for our submission, we
divided them into segments of 5 seconds. For each segment, we build a
Melspectrogram and its components. After that, we passed the spectrograms through
a CNN trained to obtain a 128-dimensional embedding vectors. Once we obtained
the vectors, we use this to predict, using a classi er, a possible specie present on
this part of that audio.</p>
      <p>As our model is still not very accurate, for each 5 seconds piece of audio
we get the 10 rst possible species pointed out by the classi er and put them
into submission le, given a higher weight to the rst one and lower weight to
the last one. We also take into account, and cut o , the species that does not
belong to that region where the current soundscapes were recorded. The list with
species per region and the information where each soundscape were recorded was
provided along with the dataset.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Results</title>
      <p>To evaluate the system, the competition provides a well-known ranking metric,
the Mean Average Precision (MAP). But in this case, divided into two parts.
The sample-wise mean average precision (r-mAP), the classic one, and the
classwise mean average precision, which takes the average precision (c-mAP) among
the classes. Bellow, we have the equation for MAP, where Q is the number of
test audio les and AveP(q) is an Average Precision for q le computed on
equation 3:</p>
      <p>M AP =</p>
      <p>PQ
q=0 AveP (q)</p>
      <p>Q
;
(2)
and</p>
      <p>AveP = PkN=0(P (k) rel(k)) ; (3)</p>
      <p>num relevant documents
where k is the rank in the sequence of returned species, n is the total number
of returned species, P (k) is the precision at cut-o k in the list and rel(k) is an
indicator function equaling 1 if the item at rank k is a relevant species.</p>
      <p>
        Table 5 shows the results for the submissions made, 1 and 2 made during the
competition and the others made after the competition ended. The submission
4 and 5 use the same train con guration, the di erence between them is that on
submission time instead of given higher weight to the rst one and lower weight,
we assign a weight for all species equal to 1.
We applied a Siamese Network with Triplet Loss to the task of Bird Sounds
Recognition. Our results were not the best, but we believe they can be improved.
This is an initial study on this theme, from here a better study can be carried
out. In this work we don't do any kind of data augmentation, a good work with
augmentation techniques can be made with noise injection, as in [
        <xref ref-type="bibr" rid="ref7 ref9">9, 7</xref>
        ]. Therefore
algorithms as Noise Reduction and per-channel energy normalization [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] still
can be used on the preprocessing stage to make learning a simpler task.
      </p>
      <p>
        On train stage, a better hyperparameter optimization should be done to
achieve the optimal result, not only empirically choices. Furthermore, a di erent
approach to the selection of the triplets can be tested, such as the dynamic
triplet loss in which the margin varies according to the progress of the training
[
        <xref ref-type="bibr" rid="ref14">14</xref>
        ].
      </p>
      <p>The implementation made to run all the submissions mentioned here are
available on https://github.com/clementino1971/BirdCLEF_2020. We would
like to thank CLEF for organizing competitions of this type and encouraging
research in this context of bioacoustic.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Librosa</surname>
          </string-name>
          <article-title>: audio and music processing in python</article-title>
          , https://librosa.org/
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2. Pydub:
          <article-title>Manipulate audio with a simple and easy high level interface</article-title>
          , https:// pydub.com/
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Driedger</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , Muller,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Disch</surname>
          </string-name>
          ,
          <string-name>
            <surname>S.</surname>
          </string-name>
          :
          <article-title>Extending harmonic-percussive separation of audio signals</article-title>
          .
          <source>In: ISMIR</source>
          . pp.
          <volume>611</volume>
          {
          <issue>616</issue>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Honka</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>One-shot learning with siamese networks for environmental audio (</article-title>
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Joly</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          , Goeau, H.,
          <string-name>
            <surname>Kahl</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Deneu</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Servajean</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cole</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Picek</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          , Ruiz De Castan~eda, R., e, Lorieul,
          <string-name>
            <given-names>T.</given-names>
            ,
            <surname>Botella</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            ,
            <surname>Glotin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            ,
            <surname>Champ</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            ,
            <surname>Vellinga</surname>
          </string-name>
          ,
          <string-name>
            <surname>W.P.</surname>
          </string-name>
          , Stoter,
          <string-name>
            <given-names>F.R.</given-names>
            ,
            <surname>Dorso</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Bonnet</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Eggel</surname>
          </string-name>
          ,
          <string-name>
            <surname>I.</surname>
          </string-name>
          , Muller, H.:
          <article-title>Overview of lifeclef 2020: a system-oriented evaluation of automated species identi cation and species distribution prediction</article-title>
          .
          <source>In: Proceedings of CLEF</source>
          <year>2020</year>
          ,
          <article-title>CLEF: Conference and Labs of the Evaluation Forum</article-title>
          , Sep.
          <year>2020</year>
          , Thessaloniki,
          <string-name>
            <surname>Greece.</surname>
          </string-name>
          (
          <year>2020</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Kahl</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Clapp</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hopping</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          , Goeau, H.,
          <string-name>
            <surname>Glotin</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Planque</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vellinga</surname>
            ,
            <given-names>W.P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Joly</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Overview of birdclef 2020: Bird sound recognition in complex acoustic environments</article-title>
          .
          <source>In: CLEF task overview</source>
          <year>2020</year>
          ,
          <article-title>CLEF: Conference and Labs of the Evaluation Forum</article-title>
          , Sep.
          <year>2020</year>
          , Thessaloniki,
          <string-name>
            <surname>Greece.</surname>
          </string-name>
          (
          <year>2020</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Kahl</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wilhelm-Stein</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hussein</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Klinck</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kowerko</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ritter</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Eibl</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Large-scale bird sound classi cation using convolutional neural networks</article-title>
          .
          <source>In: CLEF (Working Notes)</source>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Koch</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zemel</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Salakhutdinov</surname>
          </string-name>
          , R.:
          <article-title>Siamese neural networks for one-shot image recognition</article-title>
          .
          <source>In: ICML deep learning workshop</source>
          . vol.
          <volume>2</volume>
          .
          <string-name>
            <surname>Lille</surname>
          </string-name>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Lasseck</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Bird species identi cation in soundscapes</article-title>
          .
          <source>CLEF working notes</source>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Lostanlen</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Salamon</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Farnsworth</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kelling</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bello</surname>
            ,
            <given-names>J.P.</given-names>
          </string-name>
          :
          <article-title>Robust sound event detection in bioacoustic sensor networks</article-title>
          .
          <source>PloS one</source>
          <volume>14</volume>
          (
          <issue>10</issue>
          ),
          <year>e0214168</year>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Manocha</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Badlani</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kumar</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shah</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Elizalde</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Raj</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Contentbased representations of audio using siamese neural networks</article-title>
          .
          <source>In: 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)</source>
          . pp.
          <volume>3136</volume>
          {
          <fpage>3140</fpage>
          .
          <string-name>
            <surname>IEEE</surname>
          </string-name>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Schro</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kalenichenko</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Philbin</surname>
          </string-name>
          , J.:
          <article-title>Facenet: A uni ed embedding for face recognition and clustering</article-title>
          .
          <source>In: Proceedings of the IEEE conference on computer vision and pattern recognition</source>
          . pp.
          <volume>815</volume>
          {
          <issue>823</issue>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Tao</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gavves</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Smeulders</surname>
            ,
            <given-names>A.W.</given-names>
          </string-name>
          :
          <article-title>Siamese instance search for tracking</article-title>
          .
          <source>In: Proceedings of the IEEE conference on computer vision and pattern recognition</source>
          . pp.
          <volume>1420</volume>
          {
          <issue>1429</issue>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Thakur</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Thapar</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rajan</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Nigam</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Deep metric learning for bioacoustic classi cation: Overcoming training data scarcity using dynamic triplet loss</article-title>
          .
          <source>The Journal of the Acoustical Society of America</source>
          <volume>146</volume>
          (
          <issue>1</issue>
          ),
          <volume>534</volume>
          {
          <fpage>547</fpage>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Fang</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lang</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yuan</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Su</surname>
            ,
            <given-names>M.Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Baldi</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>A multi-resolution approach for spinal metastasis detection using deep siamese neural networks</article-title>
          .
          <source>Computers in biology and medicine 84</source>
          ,
          <volume>137</volume>
          {
          <fpage>146</fpage>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>