I am using l2_regularization Tensorflow has - tf.nn.l2_loss Can I use this?
- K.sum(K.square(K.abs(Weights)))
- tf.nn.l2_loss
Can I use this interchangeably in Keras (Tensorflow backend)?
I am using l2_regularization Tensorflow has - tf.nn.l2_loss Can I use this?
Can I use this interchangeably in Keras (Tensorflow backend)?
Yes, you can, but keep in mind that tf.nn.l2_loss
computes output = sum(t ** 2) / 2
(from documentation), so you've forgotten about multiplying by 0.5
. Also you don't have to calculate K.abs(weights)
because K.square(K.abs(weights)) == K.square(weights)
.
The differences are: