Esempio n. 1
0
print (D.shape)


#least_squares
y = np.array([1,2,3])
D = image_data[0][:,1]
print (D.ndim)
print (D)
beta = sp.least_squares(D, y)
print (beta)
'''


##############################

D = sp.build_dictionary(image_data)
y = np.random.randint(1, 71, size = 10)
#print (D)
#print (y)
beta, indices = sp.choose_atoms(D, y)
print (beta)
print (indices)



##############################Built list of files to iterate through####################################################
'''
##Big laptop
#os.chdir("C:\\Users\\Jack2\\Google Drive\\URMP\\jc2\\MNIST_Load")
##Little laptop
os.chdir("C:\\Users\\Jack\\Google Drive\\URMP\\jc2\\MNIST_Load")
Esempio n. 2
0
win1 = 100  #Window for mov avg 1
win2 = 500 #Window for mov avg 2


######################## Preprocess data - dictionary gets loaded with first num_rfields MNIST images ############################
#################################### Training data starts loading after dictionary images ########################################
dict_data = mnist.load_images(image_file, num_rfields)
training_data = mnist.load_images(image_file, num_images, num_rfields)
dict_data = [np.array(i, dtype=float) / 255 for i in dict_data]
training_data = [np.array(i, dtype=float) / 255 for i in training_data]




######################################### Initialize network dictionary and parameters ###########################################
D = sp.build_dictionary(dict_data)
network = lca.r_network(D)
network.set_parameters(lamb, tau, delta, u_stop, t_type)
network.set_dim(dict_data[0].shape)
#Save out the original dictionary
network.save_dictionary(5, 10, dict1_path, line_color = 255)




#################################################### Train dictionary ############################################################
network.set_alpha(alpha)
network.load_ims(training_data)
network.train(alpha_decay, alpha_decay_rate, alpha_decay_iters)
network.plot_rmse(win1, win2)
network.plot_decay()