-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathredo_fig5.m
51 lines (51 loc) · 1.71 KB
/
redo_fig5.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
clear;clc;clear;clc;
%% get path to folder
dot = '/Users/brandomiranda/home_simulation_research/overparametrized_experiments/';
path = fullfile(dot,'pytorch_experiments/test_runs_flatness2');
%NL
path_all_expts = fullfile(path,'/RedoFig5_Cheby/N_train_9_N_test_100_batch_size_9_perturb_freq_2500_perturb_magnitude_0.45_momentum_0.0_iterations_switch_mode_1/expt_type_DEGREES_40')
%% go through all the expt files
[train_means,test_means,w_norms_means] = get_means_of_experiments(path_all_expts);
%%
nb_iter = length(train_means);
iterations = 1:nb_iter;
fig_errors = figure;
plot(iterations,train_means);
hold on;
plot(iterations,test_means);
title('Train/Test error vs Iterations')
xlabel('number of iterations')
ylabel('l2 Error');
%
fig_w_norms = figure;
plot(iterations,w_norms_means);
title('norm of W');
xlabel('number of iterations')
ylabel('l2 norm of W');
%
saveas(fig_w_norms,'fig_w_norms');
saveas(fig_errors,'fig_errors');
saveas(fig_w_norms,'fig_w_norms','pdf');
saveas(fig_errors,'fig_errors','pdf');
%%
function [train_means,test_means,w_norms_means] = get_means_of_experiments(path_all_expts)
train_means = [];
test_means = [];
w_norms_means = [];
%
path_plus_prefix_of_all_expts = fullfile(path_all_expts,'/satid_*');
expt_data_files = dir(path_plus_prefix_of_all_expts);
expt_data_filenames = {expt_data_files.name};
for expt_file_name = expt_data_filenames
%expt_file_name
path_to_data_file = fullfile(path_all_expts,expt_file_name{1});
load(path_to_data_file)
%%
train_means = [train_means ; train_errors];
test_means = [test_means ; test_errors];
w_norms_means = [w_norms_means ; w_norms];
end
train_means = mean(train_means,1);
test_means = mean(test_means,1);
w_norms_means = mean(w_norms_means,1);
end