This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
from torch.autograd import Variable | |
def sample_gumbel(shape, eps=1e-20): | |
U = torch.rand(shape).cuda() | |
return -Variable(torch.log(-torch.log(U + eps) + eps)) |