Classification using residual vector quantization