Ejemplo n.º 1
0
 def make_latent_distributions(self, obs, out_obs):
     """
     根据 batch, mask 输出 proposal 网络和 prior 网络的输出
     No no_proposal is True, return None instead of proposal distribution.
     """
     assert obs.numpy().shape[-1] == 1
     # Proposal 网络输入是 原始图像 和 mask
     proposal_params = self.proposal_network(tf.concat([obs, out_obs], axis=-1))   # (None,1,1,32)
     proposal = normal_parse_params(proposal_params, 1e-3)
     # Prior 网络输入是 mask之后的图像 和 mask
     prior_params = self.prior_network(obs)              # 在通道上进行连接
     prior = normal_parse_params(prior_params, 1e-3)
     return proposal, prior
Ejemplo n.º 2
0
 def generate_samples_params(self, obs, k=100):
     """ k 代表采样的个数. 从 prior network 输出分布中采样, 随后输入到 generative network 中采样
     """
     prior_params = self.prior_network(obs)
     prior = normal_parse_params(prior_params, 1e-3)
     #
     samples = []
     for i in range(k):
         latent = self.reparameterize(prior)  # (batch,1,1,16) 重参数化并采样
         sample_params = self.generative_network(latent)  # (batch,28,28,1)
         samples.append(sample_params)
     return samples