I'm building a Matrix Factorization model for MovieLens dataset with batch-wise training. Loss function for the batch: $$ L_{batch} = 1/|B|\sum_{(u,i)\in{B}}(r_{ui} - \mu - b_u - b_i - p_u^Tq_i)^2 + \lambda(||p_u||^2 + ||q_i||^2) $$ $$ L_{batch} = (L_{base\_loss} + L_{reg\_loss})/|B| $$ $$ L_{base\_loss} = \sum_{(u,i)\in{B}}(r_{ui} - \mu - b_u - b_i - p_u^Tq_i)^2 $$ $$ L_{reg\_loss} = \sum_{(u,i)\in{B}}\lambda(||p_u||^2 + ||q_i||^2) $$ where $r_{ui}$ is the observed rating, $\mu$ is the global average rating, $b_u$ and $b_i$ are the average deviations of user $u$ and item $i$ from the global average rating respectively, $p_u$ and $q_i$ are the learned user embeddings and movie embeddings respectively, $B$ is the batch.

Base LossRegularization LossTotal Loss

What should I infer from regularization loss going up? Model is not able to capture the underlying information using the current embedding size, or the scale of regularization loss is too less compared to the base loss?


There is no problem with the fact that your regularization loss is going up.

The cost function of your model is a weighted sum of the regularization loss and the base loss, so during training the model looks to minimize them together, but eventually it comes to a point where it has to choose and minimize one on the expense of the other. The fact that it is prefers the base loss means that your regularization hyper-parameter is not too big (eventually your goal is to reduce the base loss).

In general terms: The goal of the regularization loss is to simplify the model during training - demanding smaller weights forces the model to increase the size of just the important weights, and not all of them. So some wights converge to very small and insignificant values, effectively reducing the number of weights in the model. Smaller model means less overfitting and more generalization.

In your case: During the training of your model, it starts from reducing the regularization loss (because it is an easy task), but at some point it starts to notice crucial features which it wants to emphasize so it begins to increase the weights of those features, which results in higher regularization loss but a smaller total loss (a good thing, it is learning but is also under control).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.