  Measurement of the ultra-rare $K^+\to\pi^+\nu\bar\nu$ decay at the NA62
experiment at CERN requires high-performance particle identification to
distinguish muons from pions. Calorimetric identification currently in use,
based on a boosted decision tree algorithm, achieves a muon misidentification
probability of $1.2\times 10^{-5}$ for a pion identification efficiency of 75%
in the momentum range of 15-40 GeV/$c$. In this work, calorimetric
identification performance is improved by developing an algorithm based on a
convolutional neural network classifier augmented by a filter. Muon
misidentification probability is reduced by a factor of six with respect to the
current value for a fixed pion-identification efficiency of 75%. Alternatively,
pion identification efficiency is improved from 72% to 91% for a fixed muon
misidentification probability of $10^{-5}$.
