bar plots

This commit is contained in:
Si11ium
2019-03-12 20:40:15 +01:00
parent 120673fd79
commit 0bcc25121f
7 changed files with 181 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
import sys
sys.path += ['../', './']
import os
# Concat top Level dir to system environmental variables
sys.path += os.path.join('..', '.')
from util import *
from experiment import *
@@ -26,7 +27,7 @@ def count(counters, net, notable_nets=[]):
return counters, notable_nets
with Experiment('fixpoint-density') as exp:
exp.trials = 1000
exp.trials = 100
exp.epsilon = 1e-4
net_generators = []
for activation in ['linear', 'sigmoid', 'relu']:
@@ -43,6 +44,7 @@ with Experiment('fixpoint-density') as exp:
net = net_generator().with_params(epsilon=exp.epsilon)
name = str(net.__class__.__name__) + " activiation='" + str(net.get_keras_params().get('activation')) + "' use_bias='" + str(net.get_keras_params().get('use_bias')) + "'"
count(counters, net, notable_nets)
K.clear_session()
all_counters += [counters]
all_notable_nets += [notable_nets]
all_names += [name]
@@ -52,4 +54,6 @@ with Experiment('fixpoint-density') as exp:
for exp_id, counter in enumerate(all_counters):
exp.log(all_names[exp_id])
exp.log(all_counters[exp_id])
exp.log('\n')
exp.log('\n')
print('Done')

View File

@@ -1,6 +1,10 @@
import sys
sys.path += ['../', './']
import os
# Concat top Level dir to system environmental variables
sys.path += os.path.join('..', '.')
from util import *
from experiment import *

View File

@@ -1,6 +1,7 @@
import sys
import os
sys.path += ['../', './']
from typing import Tuple
from util import *
from experiment import *
@@ -9,10 +10,32 @@ from network import *
import keras.backend
# Concat top Level dir to system environmental variables
sys.path += os.path.join('..', '.')
def generate_counters():
"""
Initial build of the counter dict, to store counts.
:rtype: dict
:return: dictionary holding counter for: 'divergent', 'fix_zero', 'fix_sec', 'other'
"""
return {'divergent': 0, 'fix_zero': 0, 'fix_other': 0, 'fix_sec': 0, 'other': 0}
def count(counters, net, notable_nets=[]):
"""
Count the occurences ot the types of weight trajectories.
:param counters: A counter dictionary.
:param net: A Neural Network
:param notable_nets: A list to store and save intersting candidates
:rtype Tuple[dict, list]
:return: Both the counter dictionary and the list of interessting nets.
"""
if net.is_diverged():
counters['divergent'] += 1
elif net.is_fixpoint():
@@ -28,6 +51,7 @@ def count(counters, net, notable_nets=[]):
counters['other'] += 1
return counters, notable_nets
with Experiment('training_fixpoint') as exp:
exp.trials = 20
exp.selfattacks = 4
@@ -69,4 +93,4 @@ with Experiment('training_fixpoint') as exp:
for exp_id, name in enumerate(all_names):
exp.log(all_names[exp_id])
exp.log(all_data[exp_id])
exp.log('\n')
exp.log('\n')

View File

@@ -1,6 +1,8 @@
import sys
import os
sys.path += ['../', './']
# Concat top Level dir to system environmental variables
sys.path += os.path.join('..', '.')
from util import *
from experiment import *