Пример #1
0
    def _inverse(self, y, yy, nlf0=None, nlf1=None, iso=None, shutter=None):
        scale = sdn_model_params(yy, self.names)

        # 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
Пример #2
0
    def _inverse_log_det_jacobian(self,
                                  z,
                                  yy,
                                  nlf0=None,
                                  nlf1=None,
                                  iso=None,
                                  shutter=None):
        scale = sdn_model_params(yy, self.names)

        # 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.compat.v1.log(scale), axis=[1, 2, 3])
Пример #3
0
    def _forward_log_det_jacobian(self,
                                  x,
                                  yy,
                                  nlf0=None,
                                  nlf1=None,
                                  iso=None,
                                  shutter=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 = sdn_model_params(yy, self.names)

        if scale is None:
            return tf.constant(0., dtype=x.dtype, name="fldj")
        return tf.reduce_sum(tf.compat.v1.log(scale), axis=[1, 2, 3])
Пример #4
0
    def _forward(self, x, yy, nlf0=None, nlf1=None, iso=None, shutter=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 = sdn_model_params(yy, self.names)
        shift = 0.0

        y = x
        if scale is not None:
            y *= scale
        if shift is not None:
            y += shift
        return y
Пример #5
0
    def _inverse_and_log_det_jacobian(self,
                                      y,
                                      yy,
                                      nlf0=None,
                                      nlf1=None,
                                      iso=None,
                                      shutter=None):
        scale = sdn_model_params(yy, self.names)

        # tf.summary.histogram('sdn/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.compat.v1.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