Example #1
0
    if (i + 1) % 100 == 0:
        print ('Sparse Test#: ', i+1)
    Lca.set_stimulus(test_set[i][0].T)  #Need to remember that Rojas uses row vecotrs.  Transpose before passing to Rozell
    Lca.generate_sparse()
    sparse_test[:,i] = Lca.a.flatten().copy()
# Save sparse codes for later use
df2 = pandas.DataFrame(sparse_test)
df2.to_csv(sparse_path_test, index = False, header = False)
"""
sparse_test = pandas.read_csv(sparse_path_test, header=None).values


############################### Train network ###########################################


net = ff_net(layers)
if decay:
    net.set_lr_stats(learn_rate, decay_rate)
else:
    net.set_lr_stats(learn_rate)

for i in range(len(training_set)):
    if (i + 1) % 1000 == 0 and show_imnums:
        print("Training Image {}".format(i + 1))
    if decay and (i + 1) % decay_iters == 0:
        net.decay()
    net.set_input(sparse_train[:, i][:, np.newaxis])
    net.forward_prop(training_set[i][1])
    net.back_prop()

net.plot_rmse()
Example #2
0
    sys.path.append(os.path.join(base1, 'MNIST_Load'))
    sys.path.append(os.path.join(base1, 'Rozell'))
    sys.path.append(os.path.join(base1, 'Image_Class'))
    sys.path.append(os.path.join(base1, 'Projects/net'))
    os.chdir(os.path.join(base1, 'MNIST_Load'))
    file_path = base1 + '/Test/DB Classifier/Overnight run'
    

import mnist_load as mnist
import sparse_algo as sp
import r_network_class as lca
import image_class as ic
from feed_forward import ff_net


net = ff_net([3, 3, 3])
#print ("layers = {}\nnum connections = {}\n".format(net.layers, len(net.connections)))
in_data = np.repeat(1, 3).reshape(3,1)
net.set_input(in_data)
net.forward_prop(np.array([[1],[0],[0]]))
'''
print ("Dimensions of all NN variables after one forward prop:")
print ("input = {}, with bias = {}".format(net.input.shape, net.activations[0].shape))
print ("W1 = {}, W1 bias = {}, W2 = {}, W2 bias = {}"\
        .format(net.connections[0][:,:-1].shape, net.connections[0].shape,\
        net.connections[1][:,:-1].shape, net.connections[1].shape))
print ("D1 = {}, D2 = {}".format(net.D[0].shape, net.D[1].shape))
print ("activations = {}, {}, {}".format(net.activations[0].shape,\
        net.activations[1].shape, net.activations[2].shape))
print ("output = {}".format(net.output.shape))
'''