Public Member Functions | Public Attributes | List of all members
googlenet_custom_layers.LRN Class Reference
Inheritance diagram for googlenet_custom_layers.LRN:

Public Member Functions

def __init__ (self, alpha=0.0001, k=1, beta=0.75, n=5, kwargs)
 
def call (self, x, mask=None)
 
def get_config (self)
 

Public Attributes

 alpha
 
 k
 
 beta
 
 n
 

Detailed Description

Definition at line 4 of file googlenet_custom_layers.py.

Constructor & Destructor Documentation

def googlenet_custom_layers.LRN.__init__ (   self,
  alpha = 0.0001,
  k = 1,
  beta = 0.75,
  n = 5,
  kwargs 
)

Definition at line 6 of file googlenet_custom_layers.py.

6  def __init__(self, alpha=0.0001,k=1,beta=0.75,n=5, **kwargs):
7  self.alpha = alpha
8  self.k = k
9  self.beta = beta
10  self.n = n
11  super(LRN, self).__init__(**kwargs)
12 
def __init__(self, alpha=0.0001, k=1, beta=0.75, n=5, kwargs)

Member Function Documentation

def googlenet_custom_layers.LRN.call (   self,
  x,
  mask = None 
)

Definition at line 13 of file googlenet_custom_layers.py.

13  def call(self, x, mask=None):
14  b, ch, r, c = x.shape
15  half_n = self.n // 2 # half the local region
16  input_sqr = T.sqr(x) # square the input
17  extra_channels = T.alloc(0., b, ch + 2*half_n, r, c) # make an empty tensor with zero pads along channel dimension
18  input_sqr = T.set_subtensor(extra_channels[:, half_n:half_n+ch, :, :],input_sqr) # set the center to be the squared input
19  scale = self.k # offset for the scale
20  norm_alpha = self.alpha / self.n # normalized alpha
21  for i in range(self.n):
22  scale += norm_alpha * input_sqr[:, i:i+ch, :, :]
23  scale = scale ** self.beta
24  x = x / scale
25  return x
26 
def googlenet_custom_layers.LRN.get_config (   self)

Definition at line 27 of file googlenet_custom_layers.py.

27  def get_config(self):
28  config = {"alpha": self.alpha,
29  "k": self.k,
30  "beta": self.beta,
31  "n": self.n}
32  base_config = super(LRN, self).get_config()
33  return dict(list(base_config.items()) + list(config.items()))
34 
35 

Member Data Documentation

googlenet_custom_layers.LRN.alpha

Definition at line 7 of file googlenet_custom_layers.py.

googlenet_custom_layers.LRN.beta

Definition at line 9 of file googlenet_custom_layers.py.

googlenet_custom_layers.LRN.k

Definition at line 8 of file googlenet_custom_layers.py.

googlenet_custom_layers.LRN.n

Definition at line 10 of file googlenet_custom_layers.py.


The documentation for this class was generated from the following file: