Skip to content

Instantly share code, notes, and snippets.

View madrugado's full-sized avatar

Valentin Malykh madrugado

View GitHub Profile
def sample_gumbel(shape, eps=1e-20):
"""Sample from Gumbel(0, 1)"""
U = tf.random_uniform(shape,minval=0,maxval=1)
return -tf.log(-tf.log(U + eps) + eps)
def gumbel_softmax_sample(logits, temperature):
""" Draw a sample from the Gumbel-Softmax distribution"""
y = logits + sample_gumbel(tf.shape(logits))
return tf.nn.softmax( y / temperature)
import random
import matplotlib.pyplot as plt
from IPython import display
"""
IPython Display rc0
Try:
dsp = IDisplay()