Run Hebbian pruning with non-binary activations.
Attempt pruning given intuition offered up in "Memory Aware Synapses" paper:
* The weights with higher coactivations computed as $x_i \times x_j$
have a greater effect on the L2 norm of the layers output. Here $x_i$ and $x_j$ are
the input and output activations respectively.
In [113]:
%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
In [114]:
import sys
sys.path.append("../../")
In [115]:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import glob
import tabulate
import pprint
import click
import numpy as np
import pandas as pd
from ray.tune.commands import *
from nupic.research.frameworks.dynamic_sparse.common.browser import *
In [128]:
base = 'gsc-trials-2019-10-02'
exps = [
os.path.join(base, exp) for exp in [
'gsc-BaseModel',
'gsc-Heb',
'gsc-SET',
'gsc-Static',
]
]
paths = [os.path.expanduser("~/nta/results/{}".format(e)) for e in exps]
for p in paths:
print(os.path.exists(p), p)
df = load_many(paths)
True /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-BaseModel
True /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-Heb
True /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-SET
True /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-Static
exp_name /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-BaseModel/experiment_state-2019-10-03_02-48-06.json
exp_name /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-Heb/experiment_state-2019-10-03_02-48-06.json
exp_name /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-SET/experiment_state-2019-10-03_02-48-06.json
exp_name /Users/mcaporale/nta/results/gsc-trials-2019-10-02/gsc-Static/experiment_state-2019-10-03_02-48-06.json
In [129]:
def leqauls(l1, l2):
"""
See if two list are the same.
"""
if len(l1) != len(l2):
return False
for i1, i2 in zip(l1, l1):
if i1 != i2:
return False
return True
In [130]:
df
Out[130]:
Experiment Name
train_acc_max
train_acc_max_epoch
train_acc_min
train_acc_min_epoch
train_acc_median
train_acc_last
val_acc_max
val_acc_max_epoch
val_acc_min
...
optim_alg
test_noise
weight_decay
hebbian_grow
hebbian_prune_perc
moving_average_alpha
on_perc
prune_methods
use_binary_coactivations
weight_prune_perc
0
0_model=BaseModel
0.955327
29
0.673958
0
0.943755
0.955327
0.964314
27
0.900561
...
SGD
False
0.01
NaN
NaN
NaN
NaN
NaN
NaN
NaN
1
1_model=BaseModel
0.954985
26
0.649107
0
0.940997
0.952202
0.963512
20
0.889735
...
SGD
False
0.01
NaN
NaN
NaN
NaN
NaN
NaN
NaN
2
2_model=BaseModel
0.953423
27
0.649497
0
0.942535
0.952153
0.969928
20
0.899759
...
SGD
False
0.01
NaN
NaN
NaN
NaN
NaN
NaN
NaN
3
3_model=BaseModel
0.954692
26
0.666146
0
0.941095
0.953569
0.966720
25
0.882919
...
SGD
False
0.01
NaN
NaN
NaN
NaN
NaN
NaN
NaN
4
4_model=BaseModel
0.957035
25
0.641246
0
0.944415
0.955766
0.965517
26
0.886127
...
SGD
False
0.01
NaN
NaN
NaN
NaN
NaN
NaN
NaN
5
0_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.955375
27
0.646763
0
0.942755
0.953862
0.962711
13
0.888132
...
SGD
False
0.01
True
0.3
0.6
None-None-0.4-None
None-None-dynamic-linear-None
False
None
6
1_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.951323
25
0.663802
0
0.937482
0.948443
0.965517
27
0.876103
...
SGD
False
0.01
True
0.3
0.6
None-None-0.1-None
None-None-dynamic-linear-None
False
None
7
2_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.953374
29
0.643004
0
0.941851
0.953374
0.965517
29
0.877306
...
SGD
False
0.01
True
0.3
0.6
None-None-0.4-None
None-None-dynamic-linear-None
False
None
8
3_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.952690
24
0.686993
0
0.941949
0.951714
0.963512
29
0.891740
...
SGD
False
0.01
True
0.3
0.6
None-None-0.1-None
None-None-dynamic-linear-None
False
None
9
4_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.954692
27
0.650327
0
0.943145
0.953423
0.963512
21
0.895750
...
SGD
False
0.01
True
0.3
0.6
None-None-0.4-None
None-None-dynamic-linear-None
False
None
10
5_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.951958
27
0.658725
0
0.939483
0.951860
0.961909
19
0.885325
...
SGD
False
0.01
True
0.3
0.6
None-None-0.1-None
None-None-dynamic-linear-None
False
None
11
6_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.956498
27
0.686554
0
0.943170
0.953569
0.964314
19
0.892141
...
SGD
False
0.01
True
0.3
0.6
None-None-0.4-None
None-None-dynamic-linear-None
False
None
12
7_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.951616
26
0.670833
0
0.940094
0.949565
0.960706
18
0.898957
...
SGD
False
0.01
True
0.3
0.6
None-None-0.1-None
None-None-dynamic-linear-None
False
None
13
8_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.955327
24
0.673714
0
0.944878
0.955278
0.962310
26
0.910986
...
SGD
False
0.01
True
0.3
0.6
None-None-0.4-None
None-None-dynamic-linear-None
False
None
14
9_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.953764
27
0.673079
0
0.942388
0.952983
0.967121
16
0.892943
...
SGD
False
0.01
True
0.3
0.6
None-None-0.1-None
None-None-dynamic-linear-None
False
None
15
0_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.957231
27
0.680988
0
0.943951
0.954057
0.967923
29
0.892542
...
SGD
False
0.01
False
None
NaN
None-None-0.4-None
None-None-dynamic-linear-None
NaN
0.3
16
1_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.952446
27
0.659604
0
0.941583
0.950786
0.961909
26
0.884122
...
SGD
False
0.01
False
None
NaN
None-None-0.1-None
None-None-dynamic-linear-None
NaN
0.3
17
2_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.955620
29
0.670735
0
0.943340
0.955620
0.966319
27
0.899358
...
SGD
False
0.01
False
None
NaN
None-None-0.4-None
None-None-dynamic-linear-None
NaN
0.3
18
3_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.953862
24
0.682746
0
0.941290
0.953276
0.967121
21
0.901764
...
SGD
False
0.01
False
None
NaN
None-None-0.1-None
None-None-dynamic-linear-None
NaN
0.3
19
4_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.954692
27
0.670052
0
0.941021
0.951665
0.966319
29
0.887731
...
SGD
False
0.01
False
None
NaN
None-None-0.4-None
None-None-dynamic-linear-None
NaN
0.3
20
5_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.954301
29
0.677375
0
0.940436
0.954301
0.961107
21
0.893745
...
SGD
False
0.01
False
None
NaN
None-None-0.1-None
None-None-dynamic-linear-None
NaN
0.3
21
6_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.955815
29
0.674251
0
0.944317
0.955815
0.962310
22
0.900160
...
SGD
False
0.01
False
None
NaN
None-None-0.4-None
None-None-dynamic-linear-None
NaN
0.3
22
7_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.954155
26
0.680402
0
0.941388
0.952837
0.959503
22
0.889735
...
SGD
False
0.01
False
None
NaN
None-None-0.1-None
None-None-dynamic-linear-None
NaN
0.3
23
8_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.956498
25
0.653989
0
0.942437
0.956205
0.966319
24
0.883320
...
SGD
False
0.01
False
None
NaN
None-None-0.4-None
None-None-dynamic-linear-None
NaN
0.3
24
9_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.951714
27
0.685187
0
0.939215
0.951274
0.963512
25
0.888532
...
SGD
False
0.01
False
None
NaN
None-None-0.1-None
None-None-dynamic-linear-None
NaN
0.3
25
0_model=SparseModel,on_perc=[None, None, 0.4, ...
0.956352
27
0.636266
0
0.940851
0.952495
0.963111
26
0.882518
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.4-None
NaN
NaN
NaN
26
1_model=SparseModel,on_perc=[None, None, 0.1, ...
0.953130
27
0.673421
0
0.942047
0.952300
0.964715
26
0.890938
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.1-None
NaN
NaN
NaN
27
2_model=SparseModel,on_perc=[None, None, 0.4, ...
0.955571
27
0.677619
0
0.942657
0.952593
0.963512
22
0.895750
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.4-None
NaN
NaN
NaN
28
3_model=SparseModel,on_perc=[None, None, 0.1, ...
0.953178
29
0.656186
0
0.939557
0.953178
0.962310
22
0.891339
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.1-None
NaN
NaN
NaN
29
4_model=SparseModel,on_perc=[None, None, 0.4, ...
0.956450
25
0.648960
0
0.944195
0.954692
0.968324
29
0.891339
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.4-None
NaN
NaN
NaN
30
5_model=SparseModel,on_perc=[None, None, 0.1, ...
0.955083
27
0.683527
0
0.942095
0.952104
0.965116
27
0.885325
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.1-None
NaN
NaN
NaN
31
6_model=SparseModel,on_perc=[None, None, 0.4, ...
0.955278
27
0.656869
0
0.941680
0.955229
0.965517
21
0.887330
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.4-None
NaN
NaN
NaN
32
7_model=SparseModel,on_perc=[None, None, 0.1, ...
0.952837
27
0.664388
0
0.940704
0.952593
0.963111
19
0.894948
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.1-None
NaN
NaN
NaN
33
8_model=SparseModel,on_perc=[None, None, 0.4, ...
0.955913
27
0.675813
0
0.944781
0.955668
0.965918
24
0.900160
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.4-None
NaN
NaN
NaN
34
9_model=SparseModel,on_perc=[None, None, 0.1, ...
0.952202
26
0.681086
0
0.941436
0.950395
0.962310
15
0.893745
...
SGD
False
0.01
NaN
NaN
NaN
None-None-0.1-None
NaN
NaN
NaN
35 rows × 42 columns
In [131]:
# remove nans where appropriate
df['hebbian_prune_perc'] = df['hebbian_prune_perc'].replace(np.nan, 0.0, regex=True)
df['weight_prune_perc'] = df['weight_prune_perc'].replace(np.nan, 0.0, regex=True)
# distill certain values
df['on_perc'] = df['on_perc'].replace('None-None-0.1-None', 0.1, regex=True)
df['on_perc'] = df['on_perc'].replace('None-None-0.4-None', 0.4, regex=True)
df['prune_methods'] = df['prune_methods'].replace('None-None-dynamic-linear-None', 'dynamic-linear', regex=True)
In [136]:
df
Out[136]:
Experiment Name
train_acc_max
train_acc_max_epoch
train_acc_min
train_acc_min_epoch
train_acc_median
train_acc_last
val_acc_max
val_acc_max_epoch
val_acc_min
...
optim_alg
test_noise
weight_decay
hebbian_grow
hebbian_prune_perc
moving_average_alpha
on_perc
prune_methods
use_binary_coactivations
weight_prune_perc
0
0_model=BaseModel
0.955327
29
0.673958
0
0.943755
0.955327
0.964314
27
0.900561
...
SGD
False
0.01
NaN
0.0
NaN
NaN
NaN
NaN
0.0
1
1_model=BaseModel
0.954985
26
0.649107
0
0.940997
0.952202
0.963512
20
0.889735
...
SGD
False
0.01
NaN
0.0
NaN
NaN
NaN
NaN
0.0
2
2_model=BaseModel
0.953423
27
0.649497
0
0.942535
0.952153
0.969928
20
0.899759
...
SGD
False
0.01
NaN
0.0
NaN
NaN
NaN
NaN
0.0
3
3_model=BaseModel
0.954692
26
0.666146
0
0.941095
0.953569
0.966720
25
0.882919
...
SGD
False
0.01
NaN
0.0
NaN
NaN
NaN
NaN
0.0
4
4_model=BaseModel
0.957035
25
0.641246
0
0.944415
0.955766
0.965517
26
0.886127
...
SGD
False
0.01
NaN
0.0
NaN
NaN
NaN
NaN
0.0
5
0_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.955375
27
0.646763
0
0.942755
0.953862
0.962711
13
0.888132
...
SGD
False
0.01
True
0.3
0.6
0.4
dynamic-linear
False
0.0
6
1_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.951323
25
0.663802
0
0.937482
0.948443
0.965517
27
0.876103
...
SGD
False
0.01
True
0.3
0.6
0.1
dynamic-linear
False
0.0
7
2_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.953374
29
0.643004
0
0.941851
0.953374
0.965517
29
0.877306
...
SGD
False
0.01
True
0.3
0.6
0.4
dynamic-linear
False
0.0
8
3_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.952690
24
0.686993
0
0.941949
0.951714
0.963512
29
0.891740
...
SGD
False
0.01
True
0.3
0.6
0.1
dynamic-linear
False
0.0
9
4_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.954692
27
0.650327
0
0.943145
0.953423
0.963512
21
0.895750
...
SGD
False
0.01
True
0.3
0.6
0.4
dynamic-linear
False
0.0
10
5_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.951958
27
0.658725
0
0.939483
0.951860
0.961909
19
0.885325
...
SGD
False
0.01
True
0.3
0.6
0.1
dynamic-linear
False
0.0
11
6_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.956498
27
0.686554
0
0.943170
0.953569
0.964314
19
0.892141
...
SGD
False
0.01
True
0.3
0.6
0.4
dynamic-linear
False
0.0
12
7_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.951616
26
0.670833
0
0.940094
0.949565
0.960706
18
0.898957
...
SGD
False
0.01
True
0.3
0.6
0.1
dynamic-linear
False
0.0
13
8_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.955327
24
0.673714
0
0.944878
0.955278
0.962310
26
0.910986
...
SGD
False
0.01
True
0.3
0.6
0.4
dynamic-linear
False
0.0
14
9_model=DSNNMixedHeb,moving_average_alpha=0.6,...
0.953764
27
0.673079
0
0.942388
0.952983
0.967121
16
0.892943
...
SGD
False
0.01
True
0.3
0.6
0.1
dynamic-linear
False
0.0
15
0_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.957231
27
0.680988
0
0.943951
0.954057
0.967923
29
0.892542
...
SGD
False
0.01
False
0.0
NaN
0.4
dynamic-linear
NaN
0.3
16
1_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.952446
27
0.659604
0
0.941583
0.950786
0.961909
26
0.884122
...
SGD
False
0.01
False
0.0
NaN
0.1
dynamic-linear
NaN
0.3
17
2_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.955620
29
0.670735
0
0.943340
0.955620
0.966319
27
0.899358
...
SGD
False
0.01
False
0.0
NaN
0.4
dynamic-linear
NaN
0.3
18
3_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.953862
24
0.682746
0
0.941290
0.953276
0.967121
21
0.901764
...
SGD
False
0.01
False
0.0
NaN
0.1
dynamic-linear
NaN
0.3
19
4_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.954692
27
0.670052
0
0.941021
0.951665
0.966319
29
0.887731
...
SGD
False
0.01
False
0.0
NaN
0.4
dynamic-linear
NaN
0.3
20
5_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.954301
29
0.677375
0
0.940436
0.954301
0.961107
21
0.893745
...
SGD
False
0.01
False
0.0
NaN
0.1
dynamic-linear
NaN
0.3
21
6_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.955815
29
0.674251
0
0.944317
0.955815
0.962310
22
0.900160
...
SGD
False
0.01
False
0.0
NaN
0.4
dynamic-linear
NaN
0.3
22
7_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.954155
26
0.680402
0
0.941388
0.952837
0.959503
22
0.889735
...
SGD
False
0.01
False
0.0
NaN
0.1
dynamic-linear
NaN
0.3
23
8_model=DSNNMixedHeb,on_perc=[None, None, 0.4,...
0.956498
25
0.653989
0
0.942437
0.956205
0.966319
24
0.883320
...
SGD
False
0.01
False
0.0
NaN
0.4
dynamic-linear
NaN
0.3
24
9_model=DSNNMixedHeb,on_perc=[None, None, 0.1,...
0.951714
27
0.685187
0
0.939215
0.951274
0.963512
25
0.888532
...
SGD
False
0.01
False
0.0
NaN
0.1
dynamic-linear
NaN
0.3
25
0_model=SparseModel,on_perc=[None, None, 0.4, ...
0.956352
27
0.636266
0
0.940851
0.952495
0.963111
26
0.882518
...
SGD
False
0.01
NaN
0.0
NaN
0.4
NaN
NaN
0.0
26
1_model=SparseModel,on_perc=[None, None, 0.1, ...
0.953130
27
0.673421
0
0.942047
0.952300
0.964715
26
0.890938
...
SGD
False
0.01
NaN
0.0
NaN
0.1
NaN
NaN
0.0
27
2_model=SparseModel,on_perc=[None, None, 0.4, ...
0.955571
27
0.677619
0
0.942657
0.952593
0.963512
22
0.895750
...
SGD
False
0.01
NaN
0.0
NaN
0.4
NaN
NaN
0.0
28
3_model=SparseModel,on_perc=[None, None, 0.1, ...
0.953178
29
0.656186
0
0.939557
0.953178
0.962310
22
0.891339
...
SGD
False
0.01
NaN
0.0
NaN
0.1
NaN
NaN
0.0
29
4_model=SparseModel,on_perc=[None, None, 0.4, ...
0.956450
25
0.648960
0
0.944195
0.954692
0.968324
29
0.891339
...
SGD
False
0.01
NaN
0.0
NaN
0.4
NaN
NaN
0.0
30
5_model=SparseModel,on_perc=[None, None, 0.1, ...
0.955083
27
0.683527
0
0.942095
0.952104
0.965116
27
0.885325
...
SGD
False
0.01
NaN
0.0
NaN
0.1
NaN
NaN
0.0
31
6_model=SparseModel,on_perc=[None, None, 0.4, ...
0.955278
27
0.656869
0
0.941680
0.955229
0.965517
21
0.887330
...
SGD
False
0.01
NaN
0.0
NaN
0.4
NaN
NaN
0.0
32
7_model=SparseModel,on_perc=[None, None, 0.1, ...
0.952837
27
0.664388
0
0.940704
0.952593
0.963111
19
0.894948
...
SGD
False
0.01
NaN
0.0
NaN
0.1
NaN
NaN
0.0
33
8_model=SparseModel,on_perc=[None, None, 0.4, ...
0.955913
27
0.675813
0
0.944781
0.955668
0.965918
24
0.900160
...
SGD
False
0.01
NaN
0.0
NaN
0.4
NaN
NaN
0.0
34
9_model=SparseModel,on_perc=[None, None, 0.1, ...
0.952202
26
0.681086
0
0.941436
0.950395
0.962310
15
0.893745
...
SGD
False
0.01
NaN
0.0
NaN
0.1
NaN
NaN
0.0
35 rows × 42 columns
In [45]:
df.columns
Out[45]:
Index(['Experiment Name', 'train_acc_max', 'train_acc_max_epoch',
'train_acc_min', 'train_acc_min_epoch', 'train_acc_median',
'train_acc_last', 'val_acc_max', 'val_acc_max_epoch', 'val_acc_min',
'val_acc_min_epoch', 'val_acc_median', 'val_acc_last', 'val_acc_all',
'epochs', 'experiment_file_name', 'trial_time', 'mean_epoch_time',
'batch_size_test', 'batch_size_train', 'data_dir', 'dataset_name',
'debug_sparse', 'debug_weights', 'device', 'learning_rate', 'lr_gamma',
'lr_scheduler', 'lr_step_size', 'model', 'momentum', 'network',
'optim_alg', 'test_noise', 'weight_decay', 'hebbian_grow',
'hebbian_prune_perc', 'moving_average_alpha', 'on_perc',
'prune_methods', 'use_binary_coactivations', 'weight_prune_perc'],
dtype='object')
In [56]:
df.shape
Out[56]:
(35, 42)
In [59]:
df.iloc[34]
Out[59]:
Experiment Name 9_model=SparseModel,on_perc=[None, None, 0.1, ...
train_acc_max 0.952202
train_acc_max_epoch 26
train_acc_min 0.681086
train_acc_min_epoch 0
train_acc_median 0.941436
train_acc_last 0.950395
val_acc_max 0.96231
val_acc_max_epoch 15
val_acc_min 0.893745
val_acc_min_epoch 0
val_acc_median 0.957097
val_acc_last 0.960706
val_acc_all 0 0.893745
1 0.894547
2 0.925020
3...
epochs 30
experiment_file_name /Users/mcaporale/nta/results/gsc-trials-2019-1...
trial_time 5.56374
mean_epoch_time 0.185458
batch_size_test 1000
batch_size_train 16
data_dir ~/nta/datasets/gsc
dataset_name PreprocessedGSC
debug_sparse True
debug_weights True
device cuda
learning_rate 0.01
lr_gamma 0.9
lr_scheduler StepLR
lr_step_size 1
model SparseModel
momentum 0
network GSCHeb
optim_alg SGD
test_noise False
weight_decay 0.01
hebbian_grow NaN
hebbian_prune_perc NaN
moving_average_alpha NaN
on_perc [None, None, 0.1, None]
prune_methods NaN
use_binary_coactivations NaN
weight_prune_perc NaN
Name: 34, dtype: object
In [81]:
df.groupby('model')["model"].count()
Out[81]:
model
BaseModel 5
DSNNMixedHeb 20
SparseModel 10
Name: model, dtype: int64
In [78]:
# Did anything fail?
df[df["epochs"] < 30]["epochs"].count()
Out[78]:
0
In [79]:
# helper functions
def mean_and_std(s):
return "{:.3f} ± {:.3f}".format(s.mean(), s.std())
def round_mean(s):
return "{:.0f}".format(round(s.mean()))
stats = ['min', 'max', 'mean', 'std']
def agg(columns, filter=None, round=3):
if filter is None:
return (df.groupby(columns)
.agg({'val_acc_max_epoch': round_mean,
'val_acc_max': stats,
'model': ['count']})).round(round)
else:
return (df[filter].groupby(columns)
.agg({'val_acc_max_epoch': round_mean,
'val_acc_max': stats,
'model': ['count']})).round(round)
In [143]:
type(np.nan)
Out[143]:
float
In [150]:
df['on_perc'][0] is nan
Out[150]:
False
In [151]:
fltr = (df['model'] == 'BaseModel')
agg(['model'], fltr)
Out[151]:
val_acc_max_epoch
val_acc_max
model
round_mean
min
max
mean
std
count
model
BaseModel
24
0.964
0.97
0.966
0.003
5
In [155]:
fltr = (df['on_perc'] == 0.4) & (df['hebbian_prune_perc'] == 0.3)
agg(['model'], fltr)
Out[155]:
val_acc_max_epoch
val_acc_max
model
round_mean
min
max
mean
std
count
model
DSNNMixedHeb
22
0.962
0.966
0.964
0.001
5
In [158]:
fltr = (df['on_perc'] == 0.1) & (df['hebbian_prune_perc'] == 0.3)
agg(['model'], fltr)
Out[158]:
val_acc_max_epoch
val_acc_max
model
round_mean
min
max
mean
std
count
model
DSNNMixedHeb
22
0.961
0.967
0.964
0.003
5
In [159]:
# 40% sparse
fltr = (df['on_perc'] == 0.4) & (df['weight_prune_perc'] == 0.3)
agg(['model'], fltr)
Out[159]:
val_acc_max_epoch
val_acc_max
model
round_mean
min
max
mean
std
count
model
DSNNMixedHeb
26
0.962
0.968
0.966
0.002
5
In [160]:
# 10% sparse
fltr = (df['on_perc'] == 0.1) & (df['weight_prune_perc'] == 0.3)
agg(['model'], fltr)
Out[160]:
val_acc_max_epoch
val_acc_max
model
round_mean
min
max
mean
std
count
model
DSNNMixedHeb
23
0.96
0.967
0.963
0.003
5
In [161]:
# 40% sparse
fltr = (df['on_perc'] == 0.4) & (df['weight_prune_perc'] == 0.0)& (df['hebbian_prune_perc'] == 0.0)
agg(['model'], fltr)
Out[161]:
val_acc_max_epoch
val_acc_max
model
round_mean
min
max
mean
std
count
model
SparseModel
24
0.963
0.968
0.965
0.002
5
In [163]:
# 10% sparse
fltr = (df['on_perc'] == 0.1) & (df['weight_prune_perc'] == 0.0)& (df['hebbian_prune_perc'] == 0.0)
agg(['model'], fltr)
Out[163]:
val_acc_max_epoch
val_acc_max
model
round_mean
min
max
mean
std
count
model
SparseModel
22
0.962
0.965
0.964
0.001
5
Content source: numenta/nupic.research
Similar notebooks: