Last active
November 9, 2016 05:32
-
-
Save ericjang/0ab1531dcd521390960635bff79a44b1 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
import tensorflow as tf | |
from tensorflow.examples.tutorials.mnist import input_data | |
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
slim=tf.contrib.slim | |
Bernoulli = tf.contrib.distributions.Bernoulli | |
K=10 # number of classes | |
N=30 # number of categorical distributions | |
# input image x (shape=(batch_size,784)) | |
x = tf.placeholder(tf.float32,[None,784]) | |
# variational posterior q(y|x), i.e. the encoder (shape=(batch_size,200)) | |
net = slim.stack(x,slim.fully_connected,[512,256]) | |
# unnormalized logits for N separate K-categorical distributions (shape=(batch_size*N,K)) | |
logits_y = tf.reshape(slim.fully_connected(net,K*N,activation_fn=None),[-1,K]) | |
q_y = tf.nn.softmax(logits_y) | |
log_q_y = tf.log(q_y+1e-20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment