Last active
April 1, 2017 14:54
-
-
Save ericjang/d30ed6e2528594a6b4421f45459abe74 to your computer and use it in GitHub Desktop.
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
loss=tf.reduce_mean(-elbo) | |
lr=tf.constant(0.001) | |
train_op=tf.train.AdamOptimizer(learning_rate=lr).minimize(loss,var_list=slim.get_model_variables()) | |
init_op=tf.initialize_all_variables() | |
# get data | |
data = input_data.read_data_sets('/tmp/', one_hot=True).train | |
BATCH_SIZE=100 | |
NUM_ITERS=50000 | |
tau0=1.0 # initial temperature | |
np_temp=tau0 | |
np_lr=0.001 | |
ANNEAL_RATE=0.00003 | |
MIN_TEMP=0.5 | |
dat=[] | |
sess=tf.InteractiveSession() | |
sess.run(init_op) | |
for i in range(1,NUM_ITERS): | |
np_x,np_y=data.next_batch(BATCH_SIZE) | |
_,np_loss=sess.run([train_op,loss],{x:np_x,tau:np_temp,lr:np_lr}) | |
if i % 100 == 1: | |
dat.append([i,np_temp,np_loss]) | |
if i % 1000 == 1: | |
np_temp=np.maximum(tau0*np.exp(-ANNEAL_RATE*i),MIN_TEMP) | |
np_lr*=0.9 | |
if i % 5000 == 1: | |
print('Step %d, ELBO: %0.3f' % (i,-np_loss)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment