Skip to content

Commit e6a465b

Browse files
authored
Merge pull request #108 from lucasb-eyer/normalization
Add normalization layer.
2 parents 6c61abc + 1ee67a4 commit e6a465b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

DeepFried2/layers/Normalization.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import DeepFried2 as df
2+
3+
class Normalization(df.Module):
4+
def __init__(self, axis=-1, eps=1e-8):
5+
df.Module.__init__(self)
6+
self.axis = axis
7+
self.eps = eps
8+
9+
def symb_forward(self, symb_in):
10+
return symb_in / df.T.sqrt(self.eps + (symb_in**2).sum(axis=self.axis, keepdims=True))

DeepFried2/layers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .ELU import ELU
1212
from .Reshape import Reshape
1313
from .Flatten import Flatten
14+
from .Normalization import Normalization
1415
from .Permute import Permute
1516
from .PoolingCUDNN import PoolingCUDNN
1617
from .Sigmoid import Sigmoid

0 commit comments

Comments
 (0)