예제 #1
0
 def sample_prior(self,
                  n: int = 1,
                  seed: int = 1,
                  two_stage: bool = True) -> tf.Tensor:
     if two_stage:
         z = atleast_2d(self.latents2.sample(sample_shape=n, seed=seed))
         z = self.decoder2(z, training=False)
         qz = self.observation2(z, trainable=False)
         return tf.convert_to_tensor(qz)
     else:
         return atleast_2d(self.latents.sample(sample_shape=n, seed=seed))
 def sample_prior(self, sample_shape=(), seed=1):
     r""" Sampling from prior distribution """
     samples = []
     for latent in self.latent_layers:
         s = bk.atleast_2d(
             latent.sample(sample_shape=sample_shape, seed=seed))
         samples.append(s)
     return samples[0] if len(samples) == 1 else tuple(samples)
 def sample_data(self, sample_shape=(), seed=1):
     r""" Sample from p(X) given that the prior of X is known, this could be
 wrong since `RandomVariable` often has a default prior. """
     samples = []
     for output in self.output_layers:
         s = bk.atleast_2d(
             output.sample(sample_shape=sample_shape, seed=seed))
         samples.append(s)
     return samples[0] if len(samples) == 1 else tuple(samples)
예제 #4
0
 def sample_prior(self,
                  sample_shape: Union[int, List[int]] = (),
                  seed: int = 1) -> Union[Tensor, List[Tensor]]:
   r""" Sampling from prior distribution """
   samples = []
   for latent in self.latents:
     s = bk.atleast_2d(latent.sample(sample_shape=sample_shape, seed=seed))
     samples.append(s)
   return samples[0] if len(samples) == 1 else tuple(samples)
예제 #5
0
    def sample_observation_prior(self, n: int = 1, seed: int = 1) -> Tensor:
        """Sample from observation prior, i.e. p(X), given that the prior of X
    is known.

    Notes
    -----
    This could be wrong since `RVmeta` often has a default prior.
    """
        return bk.atleast_2d(self.observation.sample(sample_shape=n,
                                                     seed=seed))
예제 #6
0
 def sample_data(self,
                 sample_shape: Union[int, List[int]] = (),
                 seed: int = 1) -> Union[Tensor, List[Tensor]]:
   r""" Sample from p(X) given that the prior of X is known, this could be
   wrong since `RandomVariable` often has a default prior. """
   samples = []
   for output in self.observation:
     s = bk.atleast_2d(output.sample(sample_shape=sample_shape, seed=seed))
     samples.append(s)
   return samples[0] if len(samples) == 1 else tuple(samples)
예제 #7
0
 def sample_labels(self,
                   sample_shape: List[int] = (),
                   seed: int = 1) -> tf.Tensor:
     r""" Sample labels from prior of the labels distribution. """
     return bk.atleast_2d(
         self.labels.prior.sample(sample_shape=sample_shape, seed=seed))
예제 #8
0
 def sample_prior(self, n: int = 1, seed: int = 1, **kwargs) -> Tensor:
     """Sampling from prior distribution"""
     return bk.atleast_2d(self.latents.sample(sample_shape=n, seed=seed))
예제 #9
0
 def sample_labels(self, sample_shape=(), seed=1):
     return bk.atleast_2d(
         self.labels.prior.sample(sample_shape=sample_shape, seed=seed))