def make_ip(alg, s_config, h_config, n): if alg == 'hack': rval = E_Step_Scan( clip_reflections=True, rho=0.5, h_new_coeff_schedule=[h_config] * n, s_new_coeff_schedule=[s_config] * n, ) elif alg == 'cg': rval = E_Step_CG_Scan(h_new_coeff_schedule=[h_config] * n, s_max_iters=[s_config] * n) else: assert False global model rval.register_model(model) return rval
def make_ip(alg, s_config, h_config, n): if alg == 'hack': rval = E_Step_Scan( clip_reflections = True, rho = 0.5, h_new_coeff_schedule = [ h_config ] * n, s_new_coeff_schedule = [ s_config ] * n, ) elif alg == 'cg': rval = E_Step_CG_Scan( h_new_coeff_schedule = [ h_config ] * n, s_max_iters = [ s_config ] * n) else: assert False global model rval.register_model(model) return rval
init_bias_hid=init_bias_hid, init_mu=init_mu, init_alpha=init_alpha, init_B=init_B, irange=None, min_B=.01, max_B=1e6, min_alpha=.01, max_alpha=1e6, e_step=None, m_step=Grad_M_Step()) #this initial E step is just to help out the #BatchGradientInference object model.e_step = E_Step_Scan(clip_reflections=True, rho=0.5, h_new_coeff_schedule=[.1] * OVERKILL, s_new_coeff_schedule=[.3] * OVERKILL) model.e_step.register_model(model) import theano.tensor as T from theano import function def get_needed_steps(ip, X, target, tol): V = T.matrix() history = ip.infer(V, return_history=True) kls = [ip.truncated_KL(V, history_elem).mean() for history_elem in history]
W[:,i] = means[i]/norms[i] init_mu = np.asarray(norms) model = checked_call(S3C, dict(nvis = X.shape[1], nhid = len(means), init_bias_hid = inverse_sigmoid_numpy(np.asarray([ (y==i).mean() for i in xrange(y.max()+1)])), irange = 0., min_B = .1, max_B = 1e6, min_alpha = .1, max_alpha = 1e6, m_step = checked_call(Grad_M_Step, dict(learning_rate = 1.)), init_mu = init_mu, init_alpha = init_mu * 10., init_B = init_beta, e_step = E_Step_Scan( h_new_coeff_schedule = [ .1 ] * 50, s_new_coeff_schedule = [ .1 ] * 50, clip_reflections = 1, rho = 0.5 )) ) model.W.set_value(W) model.dataset_yaml_src = '!obj:pylearn2.datasets.mnist.MNIST { which_set : "train", center : 0 }' serial.save('/u/goodfeli/galatea/pddbm/config/mnist/s3c_hack.pkl',model)