Post-hoc Calibration of Neural Networks by g-Layers