Created
July 8, 2019 21:22
-
-
Save r7vme/b2bec39ab758e7f81090d163c8bff058 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with ops.name_scope(name, "l2_normalize", [x]) as name: | |
x = ops.convert_to_tensor(x, name="x") | |
square_sum = math_ops.reduce_sum(math_ops.square(x), axis, keepdims=True) | |
x_inv_norm = math_ops.rsqrt(math_ops.maximum(square_sum, epsilon)) | |
return math_ops.multiply(x, x_inv_norm, name=name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment