L2 regularization, averaged over number of examples? I have seen in different sources that, when adding L2 regularization to the objective function of our task, we need to average this regularization term by the number of examples. However, I have also seen it without this averaging. I know it is just a matter of scaling, but I would like to know if there is any general accepted convention.

Source: https://sebastianraschka.com/faq/docs/regularized-logistic-regression-performance.html
And in the machine learning course of Andrew Ng I've seen:

Source: https://www.youtube.com/watch?v=KvtGD37Rm5I
I have seen more repeatedly the first formula, but I want to know if there is any logic behind this confusion. 
Thanks for any help
 A: As you have observed, this is not standardized. But there are more variations than you have shown.
Both examples you provided have the same relative weighting (i.e., a factor of $\lambda$) between the least squares term (sum squared residuals) and the penalty term. 
In some cases, the penalty term has factor $\lambda/2m$, while the least squares term has "1/2".  One or both of the least squares term and penalty term may have a factor of 1/2 (to cancel out factor of 2 in Hessian).
The above variations don't change anything fundamentally, and can all achieve the same solution, with appropriate re-scaling of $\lambda$.  However, there are yet other variations which do fundamentally change things, and are not just a matter of re-scaling.  For instance, both the least squares term and penalty term in your examples are squared. But one or both of these could be unsquared norm, i.e., the 2-norm, not the square of the 2-norm. None of these four combinations are equivalent to each other in terms of producing the same optimal solution.  And of course, scaling variations can occur on top of the norm squaring or not variations.
Note that in the absence of a penalty term, whether the norm or square of the norm is used for the first and only term does not affect the optimal solution. But it does when a penalty is applied.
Here's a paper, http://orfe.princeton.edu/~jqfan/papers/01/penlike.pdf , where the authors do not maintain consistency in their various formulations within the single paper (look, for instance at equations 2.2 and 3.1).
