Inverse approach to atomistic modeling: Applications to a-Si:H and g-GeSe2