Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
docstring L2Normalization (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxjscience authored and szha committed Jun 6, 2018
1 parent bbb2873 commit 9909283
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions gluonnlp/model/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,21 @@ def forward(self, inputs, states=None): # pylint: disable=arguments-differ


class L2Normalization(HybridBlock):
def __init__(self, axis=-1, eps=1E-6, prefix=None, params=None):
super(L2Normalization, self).__init__(prefix=prefix, params=params)
"""Normalize the input array by dividing the L2 norm along the given axis.
..code
out = data / (sqrt(sum(data**2, axis)) + eps)
Parameters
----------
axis : int, default -1
The axis to compute the norm value.
eps : float, default 1E-6
The epsilon value to avoid dividing zero
"""
def __init__(self, axis=-1, eps=1E-6, **kwargs):
super(L2Normalization, self).__init__(**kwargs)
self._axis = axis
self._eps = eps

Expand Down

0 comments on commit 9909283

Please sign in to comment.