Generalization error bounds for two-layer neural networks with Lipschitz loss function