Calculating error or loss