Ejemplo n.º 1
0
 def sample(self, sample_shape=torch.Size()):
     shape = self._extended_shape(sample_shape)
     with torch.no_grad():
         return torch.binomial(self.total_count.expand(shape),
                               self.probs.expand(shape))
Ejemplo n.º 2
0
 def gibbs_step(v):
     mean_h = nn.Sigmoid(torch.dot(v, W) + bh)
     h = torch.binomial(mean_h)
     mean_v = nn.Sigmoid(torch.dot(h, W.T) + bv)
     v = torch.binomial(mean_v)
     return mean_v, v