Skip to content

Instantly share code, notes, and snippets.

View dddzg's full-sized avatar
🎯
Focusing

dddzg dddzg

🎯
Focusing
  • SCUT
  • Canton, China
View GitHub Profile
@dddzg
dddzg / st-gumbel.py
Created October 10, 2019 07:07 — forked from yzh119/st-gumbel.py
ST-Gumbel-Softmax-Pytorch
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))