An encoder for vector quantization neural networks