Пример #1
0
 def _inverse_log_det_jacobian(self, z, yy, nlf0=None, nlf1=None, iso=None, cam=None):
     scale = gain_model_params_ex2(iso, self.gain_init)
     scale += (z * 0.0)
     # tf.summary.histogram('fitSDN_beta1', beta1)
     # tf.summary.histogram('fitSDN_beta2', beta2)
     if scale is None:
         return tf.constant(0., dtype=z.dtype, name="ildj")
     return - tf.reduce_sum(tf.log(scale), axis=[1, 2, 3])
Пример #2
0
 def _inverse(self, y, yy, nlf0=None, nlf1=None, iso=None, cam=None):
     scale = gain_model_params_ex2(iso, self.gain_init)
     # tf.summary.histogram('fitSDN_beta1', beta1)
     # tf.summary.histogram('fitSDN_beta2', beta2)
     x = y
     if scale is not None:
         x /= scale
     if self._last_layer:
         return tf.layers.flatten(x)
     return x
Пример #3
0
    def _forward_log_det_jacobian(self, x, yy, nlf0=None, nlf1=None, iso=None, cam=None):
        if self._last_layer:
            x = tf.reshape(x, (-1, self.i0, self.i1, self.ic))
            # yy = tf.reshape(yy, (-1, self.i0, self.i1, self.ic))

        scale = gain_model_params_ex2(iso, self.gain_init)
        scale += (x * 0.0)

        if scale is None:
            return tf.constant(0., dtype=x.dtype, name="fldj")
        return tf.reduce_sum(tf.log(scale), axis=[1, 2, 3])
Пример #4
0
 def _inverse_and_log_det_jacobian(self, y, yy, nlf0=None, nlf1=None, iso=None, cam=None):
     scale = gain_model_params_ex2(iso, self.gain_init)
     scale += (y * 0.0)
     # tf.summary.histogram('gain/scale', scale)
     x = y
     if scale is not None:
         x /= scale
     if scale is None:
         log_abs_det_J_inv = tf.constant(0., dtype=y.dtype, name="ildj")
     else:
         log_abs_det_J_inv = - tf.reduce_sum(tf.log(scale), axis=[1, 2, 3])
     if self._last_layer:
         return tf.layers.flatten(x), log_abs_det_J_inv
     return x, log_abs_det_J_inv
Пример #5
0
    def _forward(self, x, yy, nlf0=None, nlf1=None, iso=None, cam=None):
        if self._last_layer:
            x = tf.reshape(x, (-1, self.i0, self.i1, self.ic))
            # yy = tf.reshape(yy, (-1, self.i0, self.i1, self.ic))

        # if yy.shape[1] == 2 * x.shape[1]:  # needs squeezing
        #     yy = squeeze2d(yy, 2)

        scale = gain_model_params_ex2(iso, self.gain_init)
        shift = 0.0

        y = x
        if scale is not None:
            y *= scale
        if shift is not None:
            y += shift
        return y