X = T.fmatrix('X') epsilon = T.fmatrix() # Make random crop from X crop_mask, updates = theano.scan(fn=random_crop, sequences=[X]) crop_X = X * crop_mask # Creating the masks reconstruction_dims, updates = theano.scan(fn=MASK_blanking, sequences=[crop_X]) prediction_dims = crop_mask - reconstruction_dims # model(input_data, epsilon, w_h, mu_w, sig_w, w_h2, w_o, b_h, mu_b, sig_b, b_h2, b_o): # Initialize Weights weights_layer_1 = init_weights((n_visible_units, n_hidden_units), name='weights_layer_1') bias_layer_1 = init_biases(n_hidden_units, name='bias_layer_1') weights_layer_mu = init_weights((n_hidden_units, n_z), name='weights_layer_mu') bias_layer_mu = init_biases(n_z, name='bias_layer_mu') weights_layer_sig = init_weights((n_hidden_units, n_z), name='weights_layer_sig') bias_layer_sig = init_biases(n_z, name='bias_layer_sig') weights_layer_2 = init_weights((n_z, n_hidden_units), name='weights_layer_2') bias_layer_2 = init_biases(n_hidden_units, name='bias_layer_2') weights_layer_y = init_weights((n_hidden_units, n_visible_units), name='weights_layer_y') bias_layer_y = init_biases(n_visible_units, name='bias_layer_y') # Build Model model_input = crop_X * reconstruction_dims X_hat, mu, sig = model(model_input, epsilon, weights_layer_1, weights_layer_mu, weights_layer_sig, weights_layer_2, weights_layer_y, bias_layer_1, bias_layer_mu, bias_layer_sig, bias_layer_2, bias_layer_y)
# Define parameters learning_rate = 0.1 n_hidden_units = 100 n_visible_units = 784 blank_proportion = .1 alpha = .5 batch_size = 100 epochs = 10 X = T.fmatrix('X') # Initialize Weights weights_layer_1 = init_weights((n_visible_units, n_hidden_units), name='weights_layer_1') bias_layer_1 = init_biases(n_hidden_units, name='bias_layer_1') weights_layer_y = init_weights((n_hidden_units, n_visible_units), name='weights_layer_y') bias_layer_y = init_biases(n_visible_units, name='bias_layer_y') # Build Model X_hat = model(X, weights_layer_1, weights_layer_y, bias_layer_1, bias_layer_y) # Loss L = -T.sum(X * T.log(X_hat) + (1 - X) * T.log(1 - X_hat), axis=1) loss = T.mean(L) # Parameter Updating params = [weights_layer_y, bias_layer_y, weights_layer_1, bias_layer_1] updates = sgd(loss, params, lr=learning_rate)
return output # Define parameters learning_rate = 0.1 n_hidden_units = 100 n_visible_units = 784 blank_proportion = .1 alpha = .5 batch_size = 100 epochs = 10 X = T.fmatrix('X') # Initialize Weights weights_layer_1 = init_weights((n_visible_units, n_hidden_units), name='weights_layer_1') bias_layer_1 = init_biases(n_hidden_units, name='bias_layer_1') weights_layer_y = init_weights((n_hidden_units, n_visible_units), name='weights_layer_y') bias_layer_y = init_biases(n_visible_units, name='bias_layer_y') # Build Model X_hat = model(X, weights_layer_1, weights_layer_y, bias_layer_1, bias_layer_y) # Loss L = - T.sum(X * T.log(X_hat) + (1 - X) * T.log(1 - X_hat), axis=1) loss = T.mean(L) # Parameter Updating params = [weights_layer_y, bias_layer_y, weights_layer_1, bias_layer_1] updates = sgd(loss, params, lr=learning_rate) # Compiling
x = x.reshape(-1, 1, 7, 16) f(x).shape jets = T.fmatrix('Jets') lepton_missing_E = T.fmatrix('lepton_and_missing_energy') high_level = T.fmatrix('high_level') n_input_units = 28 n_hidden_units = 300 n_output_units = 1 # Initialize Weights w_h = init_weights((n_input_units, n_hidden_units), name='weights_layer_1', scale=0.1) b_h = init_biases(n_hidden_units, name='bias_layer_1') w_h2 = init_weights((n_hidden_units, n_hidden_units), name='weights_layer_2') b_h2 = init_biases(n_hidden_units, name='bias_layer_2') w_h3 = init_weights((n_hidden_units, n_hidden_units), name='weights_layer_3') b_h3 = init_biases(n_hidden_units, name='bias_layer_3') w_h4 = init_weights((n_hidden_units, n_hidden_units), name='weights_layer_4') b_h4 = init_biases(n_hidden_units, name='bias_layer_4') w_o = init_weights((n_hidden_units, n_output_units), name='weights_layer_y', scale=0.001) b_o = init_biases(n_output_units, name='bias_layer_y') noise_h, noise_h2, noise_h3, noise_h4, noise_py_x = model( X, w_h, w_h2, w_h3, w_h4, w_o, b_h, b_h2, b_h3, b_h4, b_o, 0.8, [0.5, 0.5, 0.5, 0.5])