The standard for 5G communication exploits the concept of a network slice, defined as a virtualized subset of the physical resources of the 5G communication infrastructure. As a large number of network slices is deployed over a 5G network, it is necessary to determine the physical resource demand of each network slice, and how it varies over time. This serves to increase the resource efficiency of the infrastructure without degrading network slice performance. Traffic prediction is a common approach to determine this resource demand. State-of-the-art research has demonstrated the effectiveness of machine learning (ML) predictors for traffic prediction in 5G networks. In this context, however, the problem is not only the accuracy of the predictor, but also the usability of the predicted values to drive resource orchestration and scheduling mechanisms, used for resource utilization optimization while ensuring performance. In this paper, we introduce a new approach that consists on including problem domain knowledge relevant to 5G as regularization terms in the loss function used to train different state-of-the-art deep neural network (DNN) architectures for traffic prediction. Our formulation is agnostic to the technological domain, and it can obtain an improvement of up to 61,3% for traffic prediction at the base station level with respect to other widely used loss functions (MSE).