# pca = pickle.load(f) # trX=pca.transform(trX) # vlX=pca.transform(vlX) # teX=pca.transform(teX) # -----------------------SET PARAMETERS-------------------------# losses_ratio = run_parameters.losses_ratio supervised_cost_fun = run_parameters.supervised_cost_fun # -----------------------CREATE RUN FUNCTIONS------------------# # Creating the computation graph print('Building computation graph') input_var = T.fmatrix('input_var') target_var = T.fmatrix('target_var') labeled_var = T.fmatrix('labeled_var') unsupervised_graph, supervised_graph, features = build_computation_graph(input_var, run_parameters) # Train graph has dropout reconstruction, prediction = layers.get_output([unsupervised_graph, supervised_graph]) # Test graph has no dropout so deterministic = True test_reconstruction, test_prediction = layers.get_output([unsupervised_graph, supervised_graph], deterministic=True) if run_parameters.clip_unsupervised_output is not None: reconstruction = T.clip(reconstruction, run_parameters.clip_unsupervised_output[0], run_parameters.clip_unsupervised_output[1]) test_reconstruction = T.clip(test_reconstruction, run_parameters.clip_unsupervised_output[0], run_parameters.clip_unsupervised_output[1]) # Get all trainable params params = layers.get_all_params(unsupervised_graph, trainable=True) + \ layers.get_all_params(supervised_graph, trainable=True) # params = layers.get_all_params(supervised_graph)[-2:] params = utils.unique(params)
#-----------------------SET PARAMETERS-------------------------# # Set the dimension here, 1 list = 1 stack, 2 list = 2 stacks, etc... # dimensions = [[1500, 3, 200]] # example of 1 stack dimensions = [[1500, 3, 500], [1000, 3, 200]] # example of 3 stacks # Set learning ratio for unsupervised, supervised and weights regularization lr = (1.0, 1.0, 0) # -----------------------CREATE RUN FUNCTIONS------------------# # Creating the computation graph print('Building computation graph') input_shape = [None, IM_SIZE] input_var = T.fmatrix('input_var') target_var = T.fmatrix('target_var') labeled_var = T.fmatrix('labeled_var') unsupervised_graph, supervised_graph, features = build_computation_graph(input_var, input_shape, dimensions) # Train graph has dropout reconstruction = layers.get_output(unsupervised_graph) prediction = layers.get_output(supervised_graph) # Test graph has no dropout so deterministic = True test_reconstruction = layers.get_output(unsupervised_graph, deterministic=True) test_prediction = layers.get_output(supervised_graph, deterministic=True) # Get all trainable params params = layers.get_all_params(unsupervised_graph, trainable=True) + \ layers.get_all_params(supervised_graph, trainable=True) params = utils.unique(params) # Get regularizable params regularization_params = layers.get_all_params(unsupervised_graph, regularizable=True) + \ layers.get_all_params(supervised_graph, regularizable=True)