The purpose of this work is the systematic comparison of the application of two artificial neural networks (ANNs) to the surrogate modeling of the stress field in materially heterogeneous periodic polycrystalline microstructures. The first ANN is a UNet-based convolutional neural network (CNN) for periodic data, and the second is based on Fourier neural operators (FNO). Both of these were trained, validated, and tested with results from the numerical solution of the boundary-value problem (BVP) for quasi-static mechanical equilibrium in periodic grain microstructures with square domains. More specifically, these ANNs were trained to correlate the spatial distribution of material properties with the equilibrium stress field under uniaxial tensile loading. The resulting trained ANNs (tANNs) calculate the stress field for a given microstructure on the order of 1000 (UNet) to 2500 (FNO) times faster than the numerical solution of the corresponding BVP. For microstructures in the test dataset, the FNO-based tANN, or simply FNO, is more accurate than its UNet-based counterpart; the normalized mean absolute error of different stress components for the former is 0.25-0.40% as compared to 1.41-2.15% for the latter. Errors in FNO are restricted to grain boundary regions, whereas the error in U-Net also comes from within the grain. In comparison to U-Net, errors in FNO are more robust to large variations in spatial resolution as well as small variations in grain density. On other hand, errors in U-Net are robust to variations in boundary box aspect ratio, whereas errors in FNO increase as the domain becomes rectangular. Both tANNs are however unable to reproduce strong stress gradients, especially around regions of stress concentration.