Deep Learning for Primordial $B$-mode Extraction