  Efficient error-mitigation techniques demanding minimal resources is key to
quantum information processing. We propose a generic protocol to mitigate
quantum errors using detection-based quantum autoencoders. In our protocol, the
quantum data are compressed into a latent subspace while leaving errors
outside, the latter of which is then removed by a measurement and
post-selection. Compared to previously developed methods, our protocol on the
one hand requires no extra qubits, and on the other hand has a near-optimal
denoising power, in which under reasonable requirements all errors detected
outside of the latent subspace can be removed, while those inside the subspace
cannot be removed by any means. Our detection-based quantum autoencoders are
therefore particularly useful for near-term quantum devices in which
controllable qubits are limited while noise reduction is important.
