  The advances in deep neural networks (DNN) have significantly enhanced
real-time detection of anomalous data in IoT applications. However, the
complexity-accuracy-delay dilemma persists: complex DNN models offer higher
accuracy, but typical IoT devices can barely afford the computation load, and
the remedy of offloading the load to the cloud incurs long delay. In this
paper, we address this challenge by proposing an adaptive anomaly detection
scheme with hierarchical edge computing (HEC). Specifically, we first construct
multiple anomaly detection DNN models with increasing complexity, and associate
each of them to a corresponding HEC layer. Then, we design an adaptive model
selection scheme that is formulated as a contextual-bandit problem and solved
by using a reinforcement learning policy network. We also incorporate a
parallelism policy training method to accelerate the training process by taking
advantage of distributed models. We build an HEC testbed using real IoT
devices, implement and evaluate our contextual-bandit approach with both
univariate and multivariate IoT datasets. In comparison with both baseline and
state-of-the-art schemes, our adaptive approach strikes the best accuracy-delay
tradeoff on the univariate dataset, and achieves the best accuracy and F1-score
on the multivariate dataset with only negligibly longer delay than the best
(but inflexible) scheme.
