mnist.NUM_CLASSES) n = 54200 inputs = inputs[0:n] targets = targets[0:n] labels = labels[0:n] # These layers differ slightly from those in the paper. My main # motivation is to avoid having a square weight matrix between hidden # layers to avoid matrix transpose errors. num_vis = inputs.shape[1] num_hid1 = 529 # 23^2 num_hid2 = 484 # 22^2 num_top = 1936 # 44^2 batches = data.BatchIterator(inputs) initial_params = rbm.initial_params(num_hid1, num_vis) params = sgd(rbm_obj, initial_params, batches, momentum) inputs = logistic(inputs.dot(params.W.T) + params.h_bias) batches = data.BatchIterator(inputs) initial_params = rbm.initial_params(num_hid2, num_hid1) params = sgd(rbm_obj, initial_params, batches, momentum) inputs = logistic(inputs.dot(params.W.T) + params.h_bias) batches = data.BatchIterator(np.hstack((targets, inputs))) initial_params = rbm.initial_params(num_top, num_hid2 + mnist.NUM_CLASSES) def post_epoch(*args): print 'Mean hidden activation prob. is %.2f' % pcd.q
# data inputs = mnist.load_inputs(DATA_PATH, mnist.TRAIN_INPUTS) labels = mnist.load_labels(DATA_PATH, mnist.TRAIN_LABELS) inputs = data.balance_classes(inputs, labels, mnist.NUM_CLASSES).inputs batches = data.BatchIterator(inputs[0:54200]) # IDEA: Have a bit of code which loads the current file (as text) and # dumps and code between two specific comments into a meta.txt file in # the output directory. # meta num_vis = inputs.shape[1] num_hid = 49 epochs = 10 k = 1 # applies to cd only initial_params = rbm.initial_params(num_hid, num_vis) weight_constraint = None # weight_decay = reg.l2(0.0002) # weight_decay = None # momentum = meta.linear(0.5, 0.9, 10) momentum = 0 learning_rate = 0.1 def generate(params, n=1, start=1, step=20, count=100): # Use the probability as pixel intensities. # This means we can't use the very first sample from the chain, as # it has v_mean == None. assert start > 0 num_vis = params.W.shape[1]
# data inputs = mnist.load_inputs(DATA_PATH, mnist.TRAIN_INPUTS) labels = mnist.load_labels(DATA_PATH, mnist.TRAIN_LABELS) inputs = data.balance_classes(inputs, labels, mnist.NUM_CLASSES).inputs batches = data.BatchIterator(inputs[0:54200]) # IDEA: Have a bit of code which loads the current file (as text) and # dumps and code between two specific comments into a meta.txt file in # the output directory. # meta num_vis = inputs.shape[1] num_hid = 49 epochs = 10 k = 1 # applies to cd only initial_params = rbm.initial_params(num_hid, num_vis) weight_constraint = None # weight_decay = reg.l2(0.0002) # weight_decay = None # momentum = meta.linear(0.5, 0.9, 10) momentum = 0 learning_rate = 0.1 def generate(params, n=1, start=1, step=20, count=100): # Use the probability as pixel intensities. # This means we can't use the very first sample from the chain, as # it has v_mean == None. assert start > 0 num_vis = params.W.shape[1] #initial_v = np.zeros((n, num_vis))
inputs, targets, labels = data.balance_classes(inputs, labels, mnist.NUM_CLASSES) n = 54200 inputs = inputs[0:n] targets = targets[0:n] labels = labels[0:n] # These layers differ slightly from those in the paper. My main # motivation is to avoid having a square weight matrix between hidden # layers to avoid matrix transpose errors. num_vis = inputs.shape[1] num_hid1 = 529 # 23^2 num_hid2 = 484 # 22^2 num_top = 1936 # 44^2 batches = data.BatchIterator(inputs) initial_params = rbm.initial_params(num_hid1, num_vis) params = sgd(rbm_obj, initial_params, batches, momentum) inputs = logistic(inputs.dot(params.W.T) + params.h_bias) batches = data.BatchIterator(inputs) initial_params = rbm.initial_params(num_hid2, num_hid1) params = sgd(rbm_obj, initial_params, batches, momentum) inputs = logistic(inputs.dot(params.W.T) + params.h_bias) batches = data.BatchIterator(np.hstack((targets, inputs))) initial_params = rbm.initial_params(num_top, num_hid2 + mnist.NUM_CLASSES) def post_epoch(*args): print 'Mean hidden activation prob. is %.2f' % pcd.q # Optimization objective for the top-level RBM.