Skip to content

Commit 84237ff

Browse files
author
Alexander Ororbia
committed
commit probes/mods to utils to analysis_tools branch
1 parent 796178d commit 84237ff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ngclearn/utils/model_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,19 @@ def threshold_cauchy(x, lmbda):
534534

535535
@jit
536536
def layer_normalize(x, shift=0., scale=1.):
537+
"""
538+
Applies layer normalization to input data `x`
539+
540+
Args:
541+
x: data to apply threshold function over
542+
543+
shift: the compensating mean/shift factor/parameters (to undo mean subtraction)
544+
545+
scale: the compensating re-scaling factor/parameters (to undo standard deviation division)
546+
547+
Returns:
548+
layer-normalized data samples `x`
549+
"""
537550
xmu = jnp.mean(x, axis=1, keepdims=True)
538551
xsigma = jnp.sqrt(jnp.mean(jnp.square(x - xmu)))
539552
_x = (x - xmu)/(xsigma + 1e-6)

0 commit comments

Comments
 (0)