Belle II Software light-2406-ragdoll
MultilayerPerceptron Class Reference
Inheritance diagram for MultilayerPerceptron:
Collaboration diagram for MultilayerPerceptron:

Public Member Functions

def __init__ (self, layers, name='mlp')
 
def from_list (cls, layers)
 
def initialize (self)
 
def __call__ (self, x)
 
def variables_to_writer (self, step, writer)
 

Public Attributes

 layers
 layer objs
 
 w
 weights
 
 b
 biases
 
 is_initialized
 collect all mlp parameters
 

Protected Member Functions

def _collect_weights_and_biases (self)
 

Detailed Description

multilayer perceptron class.

Definition at line 118 of file tensorflow_dnn_model.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  layers,
  name = 'mlp' 
)
initialization

Definition at line 123 of file tensorflow_dnn_model.py.

123 def __init__(self, layers, name='mlp'):
124 """
125 initialization
126 """
127 super().__init__(name=name)
128
129
130 self.layers = layers
131
132
133 self.w = None
134
135
136 self.b = None
137
138
139 self.is_initialized = False
140 self.initialize()
141

Member Function Documentation

◆ __call__()

def __call__ (   self,
  x 
)
Run the events through all the layers

Definition at line 181 of file tensorflow_dnn_model.py.

181 def __call__(self, x):
182 """
183 Run the events through all the layers
184 """
185 for layer in self.layers:
186 x = layer(x)
187 return x
188

◆ _collect_weights_and_biases()

def _collect_weights_and_biases (   self)
protected
collect tunable parameters

Definition at line 154 of file tensorflow_dnn_model.py.

154 def _collect_weights_and_biases(self):
155 """
156 collect tunable parameters
157 """
158 self.w = []
159 self.b = []
160 for layer in self.layers:
161 self.w.append(layer.w)
162 self.b.append(layer.b)
163

◆ from_list()

def from_list (   cls,
  layers 
)
define layers from list

Definition at line 143 of file tensorflow_dnn_model.py.

143 def from_list(cls, layers):
144 """
145 define layers from list
146 """
147 layer_obj = []
148 for layer in layers:
149 layer_obj.append(Layer(*layer))
150
151 mlp = cls(layer_obj)
152 return mlp
153

◆ initialize()

def initialize (   self)
initialize. Checks that the layer dimensions align.

Definition at line 164 of file tensorflow_dnn_model.py.

164 def initialize(self):
165 """
166 initialize. Checks that the layer dimensions align.
167 """
168 if self.is_initialized:
169 raise RuntimeError
170
171 # check shape
172 for _idx in range(len(self.layers) - 1):
173 assert self.layers[_idx].shape[1] == self.layers[_idx + 1].shape[0]
174
175 self._collect_weights_and_biases() # TODO - remove?
176
177 self.is_initialized = True
178 return
179

◆ variables_to_writer()

def variables_to_writer (   self,
  step,
  writer 
)
passes all the MLP variables to the tf.summary writer

Definition at line 189 of file tensorflow_dnn_model.py.

189 def variables_to_writer(self, step, writer):
190 """
191 passes all the MLP variables to the tf.summary writer
192 """
193 for layer in self.layers:
194 layer.all_to_summary(step, writer)
195 return
196
197

Member Data Documentation

◆ b

b

biases

Definition at line 136 of file tensorflow_dnn_model.py.

◆ is_initialized

is_initialized

collect all mlp parameters

Definition at line 139 of file tensorflow_dnn_model.py.

◆ layers

layers

layer objs

Definition at line 130 of file tensorflow_dnn_model.py.

◆ w

w

weights

Definition at line 133 of file tensorflow_dnn_model.py.


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