Analyzing and Improving the Reliability of Matrix Multiplication and Neural Networks on FPGAs