It sounds like you’re working on a really interesting project with anomaly detection using autoencoders in Edge Impulse! It’s frustrating to hit those errors when you’re so close.
Here’s a question you can post on the Edge Impulse forum to get some help, along with the key points you’ll want to highlight:
Edge Impulse Forum Question: Custom Learning Block for Autoencoder Anomaly Detection
Hello Edge Impulse Community,
I’m currently working on implementing an autoencoder for anomaly detection as a custom learning block in Edge Impulse, and I’m encountering some challenges.
My goal is to train the autoencoder on normal data only, then use the reconstruction error to classify anomalies. Specifically, I want to establish a threshold based on the normal data’s reconstruction errors. During inference, if the reconstruction error of a new data point exceeds this threshold, it should be flagged as anomalous; otherwise, it should be considered normal.
I’ve successfully integrated my autoencoder model into the Edge Impulse interface. However, I’m facing two main issues:
- Output Interpretation: The custom learning block currently seems to interpret the output as “classes” rather than a continuous reconstruction error or a single anomaly score. How can I configure the custom learning block to output a numerical reconstruction error (or a similar anomaly score) that I can then use for thresholding, instead of a categorical class prediction?
- Thresholding and Classification: What’s the recommended approach within Edge Impulse for applying a post-processing threshold to the autoencoder’s output (reconstruction error) to classify data as “normal” or “anomaly”? Is there a way to integrate this thresholding logic directly into the custom learning block, or should this be handled in a separate processing step (e.g., in the impulse or a custom inference script)?
Any guidance on how to correctly set up a custom learning block for this type of autoencoder-based anomaly detection, particularly regarding output configuration and thresholding, would be greatly appreciated. Are there specific considerations or best practices I should be aware of when implementing this?
Thank you for your time and help!