Physics-constrained 3D Convolutional Neural Networks for Electrodynamics