A neural network approach for the solution of electric and magnetic inverse problems