Skip to content
Permalink
Browse files

Moving multiplication of l1/l2 out of reduce_sum for better performance.

PiperOrigin-RevId: 238736890
  • Loading branch information...
tensorflower-gardener committed Mar 16, 2019
1 parent a048010 commit 82dfc6633e23b19e65f94975ccf1d00b737eb511
Showing with 2 additions and 2 deletions.
  1. +2 −2 tensorflow/python/keras/regularizers.py
@@ -58,9 +58,9 @@ def __call__(self, x):
return K.constant(0.)
regularization = 0.
if self.l1:
regularization += math_ops.reduce_sum(self.l1 * math_ops.abs(x))
regularization += self.l1 * math_ops.reduce_sum(math_ops.abs(x))
if self.l2:
regularization += math_ops.reduce_sum(self.l2 * math_ops.square(x))
regularization += self.l2 * math_ops.reduce_sum(math_ops.square(x))
return regularization

def get_config(self):

0 comments on commit 82dfc66

Please sign in to comment.
You can’t perform that action at this time.