1
$\begingroup$

I would like to use variance of weights from a NN layer in my loss function. I mean:

$L=\frac{1}{2}\sum(y-\hat{y})^2 - \alpha var(W)$

And the question:

Is it possible to have a gradient from weights variance? Does it make any sense?

$\endgroup$
1
$\begingroup$

I don't see why not, the formula for variance is:

It is fully differentiable so it can be used as part of the loss function during training. I don't know what will be the regularizing effect of it on the training, but technically it should work (from you loss function it seems that you are trying to induce different weights).

$\endgroup$
  • $\begingroup$ thank you for the answer, I also thought the same way. I just wanted to be sure. $\endgroup$ – Paddy Jan 31 at 11:02

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.