input_layer_outputs = input_neuron.input_rates_sparse(rat_data[i*batch_size:((i+1)*batch_size), :])
    b = datetime.datetime.now().replace(microsecond=0)
    # io.mmwrite(INPUT_LAYER_OUTPUTS, input_layer_outputs) #write sparse matrix to a file in COO format
    print 'number of nnz from input layer ' + str(input_layer_outputs.nnz)
    print 'input processed in ' + str(b-a)

    a = datetime.datetime.now().replace(microsecond=0)
    output_layer.process_all_inputs(input_layer_outputs)
    b = datetime.datetime.now().replace(microsecond=0)
    print 'output processed in ' + str(b-a)

output_layer.save_data_to_disk()


for i in range(100):
    weights = input_neuron.reshape_vec_to_grid(output_layer.weights[i, :])
    plt.matshow(weights)
    plt.colorbar()
    plt.title('Weights of neuron ' + str(i))
    plt.savefig('results/' + SUB_DIR + '/neuron_w_' + str(i) +'.png', format="png")
    plt.close()

    plt.matshow(autocorrelation.autocorrelation_normalized(weights))
    plt.colorbar()
    plt.title('Autocorr. of neuron ' + str(i))
    plt.savefig('results/' + SUB_DIR + '/neuron_a_' + str(i) +'.png', format="png")
    plt.close()



# plt.plot(output_layer.output_layer_outputs)
Beispiel #2
0
import numpy as np
import autocorrelation
import matplotlib.pyplot as plt
import input_neuron

SUB_DIR = './results/9M'
FILE = 'weights.npz'
f = np.load(SUB_DIR + '/' + FILE)

network_size = (100, 400)

arr = f['arr_0']
(no_rows, no_cols) = np.shape(arr)
last_weights = np.reshape(arr[no_rows - 1, :], (network_size[0], 400),
                          order='F')

for i in range(network_size[0]):
    weights = input_neuron.reshape_vec_to_grid(last_weights[i, :])
    plt.matshow(weights)
    plt.colorbar()
    plt.title('Weights of neuron ' + str(i))
    plt.savefig(SUB_DIR + '/neuron_w_' + str(i) + '.png', format="png")
    plt.close()

    plt.matshow(autocorrelation.autocorrelation_normalized(weights))
    plt.colorbar()
    plt.title('Autocorr. of neuron ' + str(i))
    plt.savefig(SUB_DIR + '/neuron_a_' + str(i) + '.png', format="png")
    plt.close()
a = datetime.datetime.now().replace(microsecond=0)
input_layer_outputs = input_neuron.input_rates_sparse(rat_data)
b = datetime.datetime.now().replace(microsecond=0)
io.mmwrite(INPUT_LAYER_OUTPUTS,
           input_layer_outputs)  #write sparse matrix to a file in COO format
print 'number of nnz from input layer ' + str(input_layer_outputs.nnz)
print 'input processed in ' + str(b - a)

a = datetime.datetime.now().replace(microsecond=0)
output_layer = fast_output_layer.FastOutputLayer(input_layer_outputs)
output_layer.process_all_inputs()
b = datetime.datetime.now().replace(microsecond=0)
print 'output processed in ' + str(b - a)

for i in range(100):
    weights = input_neuron.reshape_vec_to_grid(output_layer.weights[i, :])
    plt.matshow(weights)
    plt.colorbar()
    plt.title('Weights of neuron ' + str(i))
    plt.savefig('results/' + SUB_DIR + '/neuron_w_' + str(i) + '.png',
                format="png")
    plt.close()

    plt.matshow(autocorrelation.autocorrelation(weights))
    plt.colorbar()
    plt.title('Autocorr. of neuron ' + str(i))
    plt.savefig('results/' + SUB_DIR + '/neuron_a_' + str(i) + '.png',
                format="png")
    plt.close()

# plt.plot(output_layer.output_layer_outputs)
import numpy as np
import autocorrelation
import matplotlib.pyplot as plt
import input_neuron

SUB_DIR = './results/9M'
FILE = 'weights.npz'
f = np.load(SUB_DIR + '/' + FILE)

network_size = (100, 400)

arr = f['arr_0']
(no_rows, no_cols) = np.shape(arr)
last_weights = np.reshape(arr[no_rows-1,:], (network_size[0], 400), order='F')

for i in range(network_size[0]):
    weights = input_neuron.reshape_vec_to_grid(last_weights[i,:])
    plt.matshow(weights)
    plt.colorbar()
    plt.title('Weights of neuron ' + str(i))
    plt.savefig(SUB_DIR + '/neuron_w_' + str(i) +'.png', format="png")
    plt.close()

    plt.matshow(autocorrelation.autocorrelation_normalized(weights))
    plt.colorbar()
    plt.title('Autocorr. of neuron ' + str(i))
    plt.savefig(SUB_DIR + '/neuron_a_' + str(i) +'.png', format="png")
    plt.close()