changed the calculation of the squared error o use the inferred network