mirror of https://github.com/VLSIDA/OpenRAM.git
Added accuracy check in regression model test.
This commit is contained in:
parent
7a60eabdfe
commit
ccf98ad5a6
|
|
@ -168,6 +168,9 @@ class regression_model(simulation):
|
||||||
|
|
||||||
|
|
||||||
def cross_validation(self):
|
def cross_validation(self):
|
||||||
|
"""Wrapper for sklean cross validation function for OpenRAM regression models.
|
||||||
|
Returns the mean accuracy for each model/output."""
|
||||||
|
|
||||||
from sklearn.model_selection import cross_val_score
|
from sklearn.model_selection import cross_val_score
|
||||||
untrained_model = self.get_model()
|
untrained_model = self.get_model()
|
||||||
|
|
||||||
|
|
@ -179,13 +182,15 @@ class regression_model(simulation):
|
||||||
output_num = 0
|
output_num = 0
|
||||||
models = {}
|
models = {}
|
||||||
debug.info(1, "Output name, mean_accuracy, std_dev")
|
debug.info(1, "Output name, mean_accuracy, std_dev")
|
||||||
|
model_scores = {}
|
||||||
for o_name in self.output_names:
|
for o_name in self.output_names:
|
||||||
output_label = labels[:,output_num]
|
output_label = labels[:,output_num]
|
||||||
scores = cross_val_score(untrained_model, features, output_label, cv=5)
|
scores = cross_val_score(untrained_model, features, output_label, cv=10)
|
||||||
debug.info(1, "{}, {}, {}".format(o_name, scores.mean(), scores.std()))
|
debug.info(1, "{}, {}, {}".format(o_name, scores.mean(), scores.std()))
|
||||||
|
model_scores[o_name] = scores.mean()
|
||||||
output_num+=1
|
output_num+=1
|
||||||
|
|
||||||
|
return model_scores
|
||||||
|
|
||||||
# Fixme - only will work for sklearn regression models
|
# Fixme - only will work for sklearn regression models
|
||||||
def save_model(self, model_name, model):
|
def save_model(self, model_name, model):
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class regression_model_test(openram_test):
|
||||||
import characterizer
|
import characterizer
|
||||||
reload(characterizer)
|
reload(characterizer)
|
||||||
from characterizer import linear_regression
|
from characterizer import linear_regression
|
||||||
|
from characterizer import neural_network
|
||||||
from sram import sram
|
from sram import sram
|
||||||
from sram_config import sram_config
|
from sram_config import sram_config
|
||||||
c = sram_config(word_size=1,
|
c = sram_config(word_size=1,
|
||||||
|
|
@ -49,31 +50,11 @@ class regression_model_test(openram_test):
|
||||||
|
|
||||||
corner = (OPTS.process_corners[0], OPTS.supply_voltages[0], OPTS.temperatures[0])
|
corner = (OPTS.process_corners[0], OPTS.supply_voltages[0], OPTS.temperatures[0])
|
||||||
|
|
||||||
m = linear_regression(s.s, tempspice, corner)
|
#m = linear_regression(s.s, tempspice, corner)
|
||||||
m.cross_validation()
|
m = neural_network(s.s, tempspice, corner)
|
||||||
|
scores = m.cross_validation()
|
||||||
# Only compare the delays
|
accuracy_requirement = 0.75
|
||||||
# spice_delays = {key:value for key, value in spice_data.items() if 'delay' in key}
|
self.assertTrue(scores['rise_delay'] >= accuracy_requirement)
|
||||||
# spice_delays['min_period'] = spice_data['min_period']
|
|
||||||
# model_delays = {key:value for key, value in model_data.items() if 'delay' in key}
|
|
||||||
# model_delays['min_period'] = model_data['min_period']
|
|
||||||
# debug.info(1,"Spice Delays={}".format(spice_delays))
|
|
||||||
# debug.info(1,"Model Delays={}".format(model_delays))
|
|
||||||
|
|
||||||
# if OPTS.tech_name == "freepdk45":
|
|
||||||
# error_tolerance = 0.25
|
|
||||||
# elif OPTS.tech_name == "scn4m_subm":
|
|
||||||
# error_tolerance = 0.25
|
|
||||||
# else:
|
|
||||||
# self.assertTrue(False) # other techs fail
|
|
||||||
|
|
||||||
# print('spice_delays', spice_delays)
|
|
||||||
# print('model_delays', model_delays)
|
|
||||||
|
|
||||||
# # Check if no too many or too few results
|
|
||||||
# self.assertTrue(len(spice_delays.keys())==len(model_delays.keys()))
|
|
||||||
|
|
||||||
# self.assertTrue(self.check_golden_data(spice_delays,model_delays,error_tolerance))
|
|
||||||
|
|
||||||
globals.end_openram()
|
globals.end_openram()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue