Optimization of the quantization of dense neural networks from an exact QUBO formulation