Bayesian Inference for PDE-based Inverse Problems using the Optimization of a Discrete Loss