Dense and Sparse Coding: Theory and Architectures