Generalization capabilities of neural networks in lattice applications