Ejemplo n.º 1
0
 def _build_fwd_pass_vars(self):
     #can't just inherit from parent due to gradient building
     self._build_fwd_pass_vars_core()
     self._activation_vars = self._build_activation_vars(
                              self._get_input_activation_vars())
     self._reference_vars = self._build_reference_vars()
     self._diff_from_reference_vars = self._build_diff_from_reference_vars()
     self._gradient_at_default_activation =\
         self._get_gradient_at_activation(self.get_reference_vars())
     self._pos_contribs, self._neg_contribs =\
         self._build_pos_and_neg_contribs()
     self._pos_mxts = B.zeros_like(self.get_activation_vars())
     self._neg_mxts = B.zeros_like(self.get_activation_vars())
Ejemplo n.º 2
0
 def _build_fwd_pass_vars(self):
     """
        It is important that all the outputs of the Node have been
         built before the node is built, otherwise the value of
         mxts will not be correct 
     """
     self._build_fwd_pass_vars_core()
     self._activation_vars =\
         self._build_activation_vars(
             self._get_input_activation_vars())
     self._reference_vars =\
      self._build_reference_vars()
     self._diff_from_reference_vars =\
      self._build_diff_from_reference_vars()
     self._pos_contribs, self._neg_contribs =\
         self._build_pos_and_neg_contribs()
     self._pos_mxts = B.zeros_like(self.get_activation_vars())
     self._neg_mxts = B.zeros_like(self.get_activation_vars())
Ejemplo n.º 3
0
def compute_mult_for_sum_then_transform(
    diff_def_act_input_vars_list, diff_def_act_output, mult_output):
    sum_diff_def_input_vars = B.zeros_like(diff_def_act_input_vars_list[0])
    for diff_def_act_var in diff_def_act_input_vars_list:
        sum_diff_def_input_vars += diff_def_act_var 
    pc_sum_diff_def_input_vars = pseudocount_near_zero(sum_diff_def_input_vars)
    scale_factor = diff_def_act_output/pc_sum_diff_def_input_vars
    #the multiplier ends up being the same for all the inputs, as
    #they were just summed
    multiplier_inp = scale_factor*mult_output
    return [multiplier_inp for x in diff_def_act_input_vars_list]
Ejemplo n.º 4
0
 def reset_mxts_updated(self):
     for output_layer in self._output_layers:
         output_layer.reset_mxts_updated()
     self._mxts = B.zeros_like(self.get_activation_vars())
     self._mxts_updated = False
     self._mxts_for_inputs_updated = False
Ejemplo n.º 5
0
 def _build_fwd_pass_vars(self):
     self._reference_vars = self._build_reference_vars()
     self._diff_from_reference_vars = self._build_diff_from_reference_vars()
     self._mxts = B.zeros_like(self.get_activation_vars())