def __init__(self, cfg, name=""): self.config = cfg # configuration object from MuonAlignmentAlgorithms/scripts/ self.name = name self.vb = util.VERBOSE() self.vb.level = cfg.verbose_level() self.vb.name = name self.lineColor = ROOT.kBlack self.yTitle = "Number of " color = ROOT.TColor() if self.config.doDT(): self.fillColor = color.GetColor("#ffe0a1") # ROOT.kGreen + 3 self.yTitle += "DTs" elif self.config.doCSC(): self.fillColor = color.GetColor("#3ffa3f") # ROOT.kBlue - 7 self.yTitle += "CSCs" else: self.fillColor = ROOT.kCyan self.yTitle += "chambers" self.histograms = {} self.coordinates = ["x", "y", "z", "phix", "phiy", "phiz"] self.units = { "x": "(mm)", "y": "(mm)", "z": "(mm)", "phix": "(mrad)", "phiy": "(mrad)", "phiz": "(mrad)" } self.tex_names = { "x": "x", "y": "y", "z": "z", "phix": r"#phi_{x}", "phiy": r"#phi_{y}", "phiz": r"#phi_{z}" } self.html_names = { "x": "δx", "y": "δy", "z": "δz", "phix": "δφ<sub>x</sub>", "phiy": "δφ<sub>y</sub>", "phiz": "δφ<sub>z</sub>" } self.latex_names = { "x": "\\delta x", "y": "\\delta y", "z": "\\delta z", "phix": "\\delta \\phi_{x}", "phiy": "\\delta \\phi_{x}", "phiz": "\\delta \\phi_{x}" } self.correction_label = r"#delta" self.uncertainty_label = r"#sigma_{fit}"
def initialize(self): """Initialize a few parameters after they've been set by user""" self.msg_svc = util.VERBOSE() self.msg_svc.level = self.verbose_level self.msg_svc.initialize() self.verbose = self.verbose_level == "DEBUG" # Set name for the model, if needed if not self.model_name: self.model_name = self.hep_data.split('/')[-1].split( '.')[0] + '_' + self.date # initialize empty dictionaries, lists self.test_data = {'X': [], 'Y': []} self.train_data = {'X': [], 'Y': []} self.test_predictions = [] self.train_predictions = [] self.fpr = [] # false positive rate self.tpr = [] # true positive rate self.histories = [] ## -- Plotting framework self.msg_svc.INFO("DL : >> Store output in {0}".format( self.output_dir)) self.plotter = DeepLearningPlotter( ) # class for plotting relevant NN information self.plotter.image_format = 'pdf' ## -- Adjust model architecture parameters (flexibilty in config file) if len(self.nNodes) == 1 and self.nHiddenLayers > 0: # All layers (initial & hidden) have the same number of nodes self.msg_svc.DEBUG( "DL : Setting all layers ({0}) to have the same number of nodes ({1})" .format(self.nHiddenLayers + 1, self.nNodes)) nodes_per_layer = self.nNodes[0] self.nNodes = [ nodes_per_layer for _ in range(self.nHiddenLayers + 1) ] # 1st layer + nHiddenLayers ## -- Adjust activation function parameter (flexibilty in config file) if len(self.activations) == 1: # Assume the same activation function for all layers (input,hidden,output) self.msg_svc.DEBUG("DL : Setting input, hidden, and output layers ({0}) \n".format(self.nHiddenLayers+2)+\ " to have the same activation function {0}".format(self.activations[0]) ) activation = self.activations[0] self.activations = [ activation for _ in range(self.nHiddenLayers + 2) ] # 1st layer + nHiddenLayers + output elif len(self.activations) == 2 and self.nHiddenLayers > 0: # Assume the last activation is for the output and the first+hidden layers have the first activation self.msg_svc.DEBUG("DL : Setting input and hidden layers ({0}) to the same activation function, {1},\n".format(self.nHiddenLayers+1,self.activations[0])+\ " and the output activation to {0}".format(self.activations[1]) ) first_hidden_act = self.activations[0] output_act = self.activations[1] self.activations = [ first_hidden_act for _ in range(self.nHiddenLayers + 1) ] + [output_act] return
def __init__(self,config): self.fitLineColor = ROOT.kRed self.fitLineWidth = 3 self.config = config self.vb = util.VERBOSE() self.vb.level = config.verbose_level() self.vb.name = "HISTOFITDRAW"
def initialize(self): #,config): """Initialize a few parameters after they've been set by user""" self.msg_svc = util.VERBOSE() self.msg_svc.level = self.verbose_level self.msg_svc.initialize() ## -- Plotting framework self.plotter.output_dir = self.output_dir self.plotter.image_format = 'pdf' # must use .pdf at the LPC return
def __init__(self, configfile, script='runPlotting.py', verbose_level="INFO"): self.filename = configfile self.vb = util.VERBOSE() self.vb.level = verbose_level self.vb.name = "CONFIG" self.configuration = {} # hold all values in dictionary (as strings) self.script = script # the script that calls this class (e..g, createJobs.py) self.set_defaults()
def __init__(self): """Give default values to member variables""" self.formatter = FormatStrFormatter('%g') # formatting axis labels self.sample_labels = {} # Formatted sample labels self.variable_labels = {} # Formatted variable labels self.backend = 'uproot' # backend for hepPlotter self.msg_svc = util.VERBOSE() # 'level' for printing statements self.output_dir = '' # directory/path to store the plots self.image_format = 'pdf' # figure format (PDF matches with backend!) self.class_pairs = None # Unique pairs of targets for comparing self.features = [] # Features used in network self.classCollection = util.NNClassCollection() # NN classes in deep learning self.CMSlabelStatus = "Simulation Internal" # plot label
def __init__(self): """Give default values to member variables""" self.date = date.today().strftime('%d%b%Y') self.betterColors = hpt.betterColors()['linecolors'] self.sample_labels = hpl.sample_labels() self.variable_labels = hpl.variable_labels() self.msg_svc = util.VERBOSE() self.filename = "" self.output_dir = '' self.image_format = 'png' self.process_label = '' # if a single process is used for all training, set this self.classification = False # 'binary','multi',False self.regression = False # True or False self.df = None self.targets = [] self.CMSlabelStatus = "Internal"
def __init__(self): """Give default values to member variables""" self.date = date.today().strftime('%d%b%Y') self.formatter = FormatStrFormatter('%g') self.betterColors = hpt.betterColors()['linecolors'] self.sample_labels = plb.sample_labels() self.variable_labels = plb.variable_labels() self.scaled_inputs = False self.msg_svc = util.VERBOSE() self.output_dir = '' self.image_format = 'pdf' self.process_label = '' # if a single process is used for all training, set this self.df = None self.targets = [] self.target_pairs = None self.CMSlabelStatus = "Simulation Internal"
def __init__(self, cfg): self.config = cfg self.vb = util.VERBOSE() self.vb.level = cfg.verbose_level() self.vb.name = "PLOTCORRECTIONS" # simple name of this script to recognize the output self.alignmentName = self.config.alignmentName() self.referenceName = self.config.referenceName() self.correctionName = self.config.correctionName() self.isDT = self.config.doDT() self.isCSC = self.config.doCSC() if (not self.isDT and not self.isCSC) or (self.isDT and self.isCSC): self.vb.ERROR( "DT and CSC set to same value. Set only one option to 'true'") sys.exit(-1) self.html = util.HTML()
if hpd not in sys.path: sys.path.insert(0, hpd) import plotlabels as plb import util from training import Training from config import Config print print " ------------------------------ " print " * Goldilocks Deep Learning * " print " ------------------------------ " print date = strftime("%d%b%Y-%H%M") vb = util.VERBOSE() ## Set configuration options ## config = Config(sys.argv[1]) vb.level = config.verbose_level vb.initialize() if not config.runTraining and not config.runInference: vb.ERROR("RUN : No configuration set ") vb.ERROR( "RUN : Please set the arguments 'runTraining' or 'runInference' to define workflow " ) vb.ERROR("RUN : Exiting.") sys.exit(1) ## Setup Deep Learning class
def initialize(self): """Initialize a few parameters that are required before running, but after __init__()""" self.msg_svc = util.VERBOSE() self.msg_svc.level = self.verbose_level return