Пример #1
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_smoothed_data

error_fb_plas_0_001_vals_iters, error_fb_plas_0_001_vals = load_object(
    './raw_data/fb_plas_0-001/sum_squares_error.pkl')
#error_fb_plas_0_00075_vals_iters, error_fb_plas_0_00075_vals = load_object('./raw_data/fb_plas_0-00075/sum_squares_error.pkl')
error_fb_plas_0_0005_vals_iters, error_fb_plas_0_0005_vals = load_object(
    './raw_data/fb_plas_0-0005/sum_squares_error.pkl')
error_fb_plas_0_00025_vals_iters, error_fb_plas_0_00025_vals = load_object(
    './raw_data/fb_plas_0-00025/sum_squares_error.pkl')
error_fb_plas_0_000125_vals_iters, error_fb_plas_0_000125_vals = load_object(
    './raw_data/fb_plas_0-000125/sum_squares_error.pkl')
error_fb_plas_0_0000625_vals_iters, error_fb_plas_0_0000625_vals = load_object(
    './raw_data/fb_plas_0-0000625/sum_squares_error.pkl')
error_fb_plas_0_00003125_vals_iters, error_fb_plas_0_00003125_vals = load_object(
    './raw_data/fb_plas_0-00003125/sum_squares_error.pkl')
error_fb_align_vals_iters, error_fb_align_feedback_vals = load_object(
    './raw_data/fb_align/sum_squares_error.pkl')

error_fb_plas_0_001_vals = get_smoothed_data(error_fb_plas_0_001_vals, 2500)
error_fb_plas_0_0005_vals = get_smoothed_data(error_fb_plas_0_0005_vals, 2500)
error_fb_plas_0_00025_vals = get_smoothed_data(error_fb_plas_0_00025_vals,
                                               2500)
error_fb_plas_0_000125_vals = get_smoothed_data(error_fb_plas_0_000125_vals,
                                                2500)
error_fb_plas_0_0000625_vals = get_smoothed_data(error_fb_plas_0_0000625_vals,
                                                 2500)
error_fb_plas_0_00003125_vals = get_smoothed_data(
    error_fb_plas_0_00003125_vals, 2500)
error_fb_align_feedback_vals = get_smoothed_data(error_fb_align_feedback_vals,
Пример #2
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object

feedforward_feedback_fb_plas_0_001_vals_iters, feedforward_feedback_fb_plas_0_001_vals = load_object('./raw_data/fb_plas_0-001/layer_1_feedforward_feedback_weight_angle.pkl')
#feedforward_feedback_fb_plas_0_00075_vals_iters, feedforward_feedback_fb_plas_0_00075_vals = load_object('./raw_data/fb_plas_0-00075/layer_1_feedforward_feedback_weight_angle.pkl')
feedforward_feedback_fb_plas_0_0005_vals_iters, feedforward_feedback_fb_plas_0_0005_vals = load_object('./raw_data/fb_plas_0-0005/layer_1_feedforward_feedback_weight_angle.pkl')
feedforward_feedback_fb_plas_0_00025_vals_iters, feedforward_feedback_fb_plas_0_00025_vals = load_object('./raw_data/fb_plas_0-00025/layer_1_feedforward_feedback_weight_angle.pkl')
feedforward_feedback_fb_plas_0_000125_vals_iters, feedforward_feedback_fb_plas_0_000125_vals = load_object('./raw_data/fb_plas_0-000125/layer_1_feedforward_feedback_weight_angle.pkl')
feedforward_feedback_fb_plas_0_0000625_vals_iters, feedforward_feedback_fb_plas_0_0000625_vals = load_object('./raw_data/fb_plas_0-0000625/layer_1_feedforward_feedback_weight_angle.pkl')
feedforward_feedback_fb_align_vals_iters, feedforward_fb_align_feedback_vals = load_object('./raw_data/fb_align/layer_1_feedforward_feedback_weight_angle.pkl')

num_vals = len(feedforward_feedback_fb_align_vals_iters)

plt.figure()
    plt.plot(feedforward_feedback_fb_plas_0_001_vals_iters[:num_vals], feedforward_feedback_fb_plas_0_001_vals[:num_vals], label='$\eta_{1, 2}^{\mathrm{PP}} = 1.0 \mathrm{x} 10^{-3}$')
#plt.plot(feedforward_feedback_fb_plas_0_00075_vals_iters[:num_vals], feedforward_feedback_fb_plas_0_00075_vals[:num_vals], label='$\eta_{1, 2}^{\mathrm{PP}} = 0.00075$')
plt.plot(feedforward_feedback_fb_plas_0_0005_vals_iters[:num_vals], feedforward_feedback_fb_plas_0_0005_vals[:num_vals], label='$\eta_{1, 2}^{\mathrm{PP}} = 5.0 \mathrm{x} 10^{-4}$')
plt.plot(feedforward_feedback_fb_plas_0_00025_vals_iters[:num_vals], feedforward_feedback_fb_plas_0_00025_vals[:num_vals], label='$\eta_{1, 2}^{\mathrm{PP}} = 2.5 \mathrm{x} 10^{-4}$')
plt.plot(feedforward_feedback_fb_plas_0_000125_vals_iters[:num_vals], feedforward_feedback_fb_plas_0_000125_vals[:num_vals], label='$\eta_{1, 2}^{\mathrm{PP}} = 1.25 \mathrm{x} 10^{-4}$')
plt.plot(feedforward_feedback_fb_plas_0_0000625_vals_iters[:num_vals], feedforward_feedback_fb_plas_0_0000625_vals[:num_vals], label='$\eta_{1, 2}^{\mathrm{PP}} = 6.25 \mathrm{x} 10^{-5}$')
plt.plot(feedforward_feedback_fb_align_vals_iters[:num_vals], feedforward_fb_align_feedback_vals[:num_vals], label='Feedback Alignment')


plt.legend(loc='upper right', prop={'size': 9})
plt.ylim((0, 100))
plt.xlabel('Iterations')
plt.ylabel('$\\angle (\mathbf{W}_{1, 2}^{\mathrm{PP}}, \mathbf{W}_{2, 1}^{\mathrm{PP}})$')
plt.savefig('figure11.pdf', bbox_inches='tight')

plt.show()
Пример #3
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_plot_data, get_smoothed_data

target_iters, target_vals = load_object('./raw_data/individual_target_value.pkl')
output_iters, output_vals = load_object('./raw_data/layer_2_individual_pyramidal_basal_potential.pkl')

print(len(target_iters))
print(len(output_iters))

num_vals = len(target_iters)
min_index_start = 1000
max_index_start = 1500

min_index_test = num_vals - 500
max_index_test = num_vals

#fig = plt.figure()

fig, ((ax_1, ax_2), (ax_3, ax_4)) = plt.subplots(2, 2, figsize=(8, 6), sharex='col')

ax_3.set_xlabel('Iterations')
ax_4.set_xlabel('Iterations')

fig.subplots_adjust(left=0.01, bottom=0.1, right=0.99, top=1.0, wspace=0.05, hspace=0.00)

l1, = ax_1.plot(target_iters[min_index_start:max_index_start], target_vals[min_index_start:max_index_start], label='Target', c='r')
l2, = ax_2.plot(target_iters[min_index_test:max_index_test], target_vals[min_index_test:max_index_test], label='Target', c='r')
l3, = ax_3.plot(output_iters[min_index_start:max_index_start], output_vals[min_index_start:max_index_start], label='Output', c='b')
l4, = ax_4.plot(output_iters[min_index_test:max_index_test], output_vals[min_index_test:max_index_test], label='Output', c='b')
Пример #4
0
#sub_folders = ['/test_500', '/test_750', '/test_1000', '/test_1250']
sub_folders = ['/test_500', '/test_750', '/test_1000']

file_base = '/monitors/'

save_location_base = 'C:/Users/Will/PycharmProjects/MScProject/figure_creation/target_network_noise/raw_data/'

train_errors = []
test_errors = []
for folder in folders:
    path_base = folder_base + folder
    best_test_error = np.inf
    best_train_error = np.inf
    for i, sub_folder in enumerate(sub_folders):
        src_path = path_base + sub_folder + file_base + 'sum_squares_error.pkl'
        data = load_object(src_path)[1]
        test_error = np.mean(data[-1000:])

        smoothed_error = get_smoothed_data(data, 35000)
        min_training_error = np.min(smoothed_error)
        best_train_error = min(min_training_error, best_train_error)
        best_test_error = min(best_test_error, test_error)

        print(test_error, min_training_error, folder, sub_folder)

    print(best_test_error, folder, 'best')
    print()
    train_errors += [best_train_error]
    test_errors += [best_test_error]

import matplotlib.pyplot as plt
Пример #5
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_plot_data, get_smoothed_data

error_raw_iters, error_raw_vals = load_object(
    './raw_data/sum_squares_error.pkl')

num_vals = len(error_raw_iters) - 100000

smoothed_train_error_values = get_smoothed_data(error_raw_vals[:num_vals],
                                                35000)
plt.figure()
plt.ylim((0, max(smoothed_train_error_values) + 0.01))
plt.plot(error_raw_iters[:num_vals], smoothed_train_error_values, c='b')
plt.xlabel('Iterations')
plt.ylabel('Training Error')
plt.savefig('figure2.pdf', bbox_inches='tight')

plt.show()
Пример #6
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_plot_data, get_smoothed_data

predict_iters, predict_vals = load_object(
    './raw_data/layer_1_feedforward_predict_weight_angle.pkl')
iterneuron_iters, interneuron_vals = load_object(
    './raw_data/layer_1_feedback_interneuron_weight_angle.pkl')

print(predict_vals[-10:])
print(interneuron_vals[-10:])

num_vals = len(predict_iters)
plt.figure()
plt.ylim((0, 100))
plt.plot(predict_iters[:num_vals], predict_vals[:num_vals], c='b')
plt.xlabel('Iterations')
plt.ylabel(
    '$\\angle (\mathbf{W}_{1, 2}^{\mathrm{PP}}, \mathbf{W}_{1, 1}^{\mathrm{IP}})$ (degrees)',
    size=12)
plt.savefig('figure3-l.pdf', bbox_inches='tight')

num_vals = len(iterneuron_iters)
plt.figure()
plt.ylim((0, 180))
plt.plot(iterneuron_iters[:num_vals], interneuron_vals[:num_vals], c='b')
plt.xlabel('Iterations')
plt.ylabel(
    '$\\angle (\mathbf{W}_{2, 1}^{\mathrm{PP}}, \mathbf{W}_{1, 1}^{\mathrm{PI}})$ (degrees)',
    size=12)
plt.savefig('figure3-r.pdf', bbox_inches='tight')
Пример #7
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_smoothed_data

fb_plas_0_001_model = load_object(
    './raw_data/fb_plas_0-001/xor_sigmoid_fb_plas_0-001.pkl')
fb_plas_0_0005_model = load_object(
    './raw_data/fb_plas_0-0005/xor_sigmoid_fb_plas_0-0005.pkl')
fb_plas_0_00025_model = load_object(
    './raw_data/fb_plas_0-00025/xor_sigmoid_fb_plas_0-00025.pkl')
fb_plas_0_000125_model = load_object(
    './raw_data/fb_plas_0-000125/xor_sigmoid_fb_plas_0-000125.pkl')
fb_plas_0_0000625_model = load_object(
    './raw_data/fb_plas_0-0000625/xor_sigmoid_fb_plas_0-0000625.pkl')
fb_plas_0_00003125_model = load_object(
    './raw_data/fb_plas_0-00003125/xor_sigmoid_fb_plas_0-00003125.pkl')
fb_align_model = load_object('./raw_data/fb_align/xor_sigmoid_fb_align.pkl')

models = [
    fb_plas_0_001_model, fb_plas_0_0005_model, fb_plas_0_00025_model,
    fb_plas_0_000125_model, fb_plas_0_0000625_model, fb_plas_0_00003125_model,
    fb_align_model
]
model_ff_weights = [
    model.get_layers()[1][1].get_feedforward_weights() for model in models
]
model_fb_weights = [
    model.get_layers()[0][1].get_feedback_weights() for model in models
]

for model_ff_weight, model_fb_weight in zip(model_ff_weights,
Пример #8
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_plot_data

target_iters, target_vals = load_object(
    './raw_data/individual_target_value.pkl')
soma_iters, soma_vals = load_object(
    './raw_data/layer_2_individual_pyramidal_soma_potential.pkl')
apical_iters, apical_vals = load_object(
    './raw_data/layer_1_individual_pyramidal_apical_potential.pkl')

plt.figure()
plt.plot(soma_iters, soma_vals, label='Output', c='b')
plt.plot(target_iters, target_vals, label='Target', c='r', linestyle='--')
plt.legend()
plt.xlabel('Iterations')
plt.ylabel('Somatic Potential')

plt.savefig('figure1-l.pdf', bbox_inches='tight')

num_vals = 500
plt.figure()
plt.plot(apical_iters[:num_vals],
         apical_vals[:num_vals],
         label='Apical Potential',
         c='b')
plt.plot(apical_iters[:num_vals],
         np.zeros(num_vals, ),
         c='black',
         linestyle='--')
#plt.legend()
Пример #9
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_plot_data, get_smoothed_data

feedforward_iters, feedforward_vals = load_object(
    './raw_data/layer_1_feedforward_feedback_weight_angle.pkl')

print(np.min(feedforward_vals))

num_vals = len(feedforward_iters)
plt.figure()
plt.ylim((0, 100))
plt.yticks([0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
plt.plot(feedforward_iters[:num_vals], feedforward_vals[:num_vals], c='b')
plt.xlabel('Iterations')
plt.ylabel(
    '$\\angle (\mathbf{W}_{1, 2}^{\mathrm{PP}}, \mathbf{W}_{2, 1}^{\mathrm{PP}})$ (degrees)',
    size=12)
plt.savefig('figure4.pdf', bbox_inches='tight')

plt.show()
Пример #10
0
import matplotlib.pyplot as plt
import numpy as np
from figure_creation.figure_helpers import load_object, get_smoothed_data

layer_1_backprop_angle_iters, layer_1_backprop_angle_vals = load_object('./raw_data/layer_1_backprop_update_angle.pkl')
smoothed_layer_1_backprop_angle_vals = get_smoothed_data(layer_1_backprop_angle_vals, 200)

layer_2_backprop_angle_iters, layer_2_backprop_angle_vals = load_object('./raw_data/layer_2_backprop_update_angle.pkl')
smoothed_layer_2_backprop_angle_vals = get_smoothed_data(layer_2_backprop_angle_vals, 200)

plt.figure()
plt.xlim((0, layer_1_backprop_angle_iters[-1]))
plt.ylim((40, 140))
plt.plot(layer_1_backprop_angle_iters, layer_1_backprop_angle_vals, c='b')
plt.plot(layer_1_backprop_angle_iters, smoothed_layer_1_backprop_angle_vals, c='r')
plt.plot(layer_1_backprop_angle_iters, [90 for a in layer_2_backprop_angle_iters], c='#bf5c00', linestyle='--')
plt.xlabel('Iterations')
plt.ylabel('$\\angle (\delta_{BP}, \delta_{DEN})$', size=12)
plt.savefig('figure20-l.pdf', bbox_inches='tight')

plt.figure()
plt.xlim((0, layer_2_backprop_angle_iters[-1]))
plt.ylim((0, 100))
plt.plot(layer_2_backprop_angle_iters, layer_2_backprop_angle_vals, c='b')
plt.plot(layer_2_backprop_angle_iters, smoothed_layer_2_backprop_angle_vals, c='r')
plt.xlabel('Iterations')
plt.ylabel('$\\angle (\delta_{BP}, \delta_{DEN})$', size=12)
plt.savefig('figure20-r.pdf', bbox_inches='tight')

plt.show()