def __init__(self, d={}, **kw): """ Retrieve from args the logger, or create it using default configuration. """ d.update(kw) from Gaugi import retrieve_kw from Gaugi.gtypes import NotSet if 'level' in d: if d['level'] not in (None, NotSet): self._level = LoggingLevel.retrieve(retrieve_kw(d, 'level')) else: d.pop('level') self._logger = retrieve_kw(d,'logger', None) or \ self.getModuleLogger( d.pop('logName', self.__class__.__name__), LoggingLevel.retrieve( self.getLevel() ) ) self._logger.verbose('Initialiazing %s', self.__class__.__name__) self._logger._ringercore_logger_parent = self if self._logger.level != LoggingLevel.MUTE: import types self._logger.setLevel = types.MethodType(_setOutputLevel, self._logger) else: self.level = LoggingLevel.MUTE def check_add(f): fname = f.__name__ self.__dict__['_' + fname] = f
def __call__(self, **kw): # Cross validation configuration outputFolder = retrieve_kw(kw, 'outputFolder', 'jobConfig') sortBounds = retrieve_kw(kw, 'sortBounds', 5) nInits = retrieve_kw(kw, 'nInits', 10) nSortsPerJob = retrieve_kw(kw, 'nSortsPerJob', 1) nInitsPerJob = retrieve_kw(kw, 'nInitsPerJob', 10) nModelsPerJob = retrieve_kw(kw, 'nModelsPerJob', 1) models = retrieve_kw(kw, 'models', [default_model]) model_tags = retrieve_kw(kw, 'model_tags', ['mlp_100_5_1']) crossval = retrieve_kw(kw, 'crossval', KFold(10, shuffle=True, random_state=512)) time_stamp = self.time_stamp() # creating the job mechanism file first mkdir_p(outputFolder) if type(models) is not list: models = [models] modelJobsWindowList = create_iter( lambda i, sorts: list(range(i, i + sorts)), nModelsPerJob, len(models)) sortJobsWindowList = create_iter( lambda i, sorts: list(range(i, i + sorts)), nSortsPerJob, sortBounds) initJobsWindowList = create_iter( lambda i, sorts: list(range(i, i + sorts)), nInitsPerJob, nInits) nJobs = 0 for (model_idx_list, sort_list, init_list) in product(modelJobsWindowList, sortJobsWindowList, initJobsWindowList): MSG_INFO( self, 'Creating job config with sort (%d to %d) and %d inits and model Index %d to %d', sort_list[0], sort_list[-1], len(init_list), model_idx_list[0], model_idx_list[-1]) from saphyra.core.readers.versions import Job_v1 job = Job_v1() # to be user by the database table job.setId(nJobs) job.setSorts(sort_list) job.setInits(init_list) job.setModels([models[idx] for idx in model_idx_list], model_idx_list) # save config file model_str = 'ml%i.mu%i' % (model_idx_list[0], model_idx_list[-1]) sort_str = 'sl%i.su%i' % (sort_list[0], sort_list[-1]) init_str = 'il%i.iu%i' % (init_list[0], init_list[-1]) job.save(outputFolder + '/' + ('job_config.ID_%s.%s_%s_%s.%s') % (str(nJobs).zfill(4), model_str, sort_str, init_str, time_stamp)) nJobs += 1 MSG_INFO(self, "A total of %d jobs...", nJobs)
def __init__(self , pattern_generator, crossval, **kw ): Logger.__init__(self) self.__pattern_generator = pattern_generator self.crossval = crossval self.optimizer = retrieve_kw( kw, 'optimizer' , 'adam' ) self.loss = retrieve_kw( kw, 'loss' , 'binary_crossentropy' ) self.epochs = retrieve_kw( kw, 'epochs' , 1000 ) self.batch_size = retrieve_kw( kw, 'batch_size' , 1024 ) self.callbacks = retrieve_kw( kw, 'callbacks' , [] ) self.metrics = retrieve_kw( kw, 'metrics' , [] ) self.sorts = retrieve_kw( kw, 'sorts' , range(1) ) self.inits = retrieve_kw( kw, 'inits' , 1 ) job_auto_config = retrieve_kw( kw, 'job' , None ) self.__verbose = retrieve_kw( kw, 'verbose' , True ) self.__class_weight = retrieve_kw( kw, 'class_weight' , False ) self.__save_history = retrieve_kw( kw, 'save_history' , True ) self.decorators = retrieve_kw( kw, 'decorators' , [] ) # read the job configuration from file if job_auto_config: if type(job_auto_config) is str: MSG_INFO( self, 'Reading job configuration from: %s', job_auto_config ) from saphyra.core.readers import JobReader job = JobReader().load( job_auto_config ) else: job = job_auto_config # retrive sort/init lists from file self.sorts = job.getSorts() self.inits = job.getInits() self.__models, self.__id_models = job.getModels() self.__jobId = job.id() # get model and tag from model file or lists models = retrieve_kw( kw, 'models', None ) if models: self.__models = models self.__id_models = [id for id in range(len(models))] self.__jobId = 0 self.__outputfile = retrieve_kw( kw, 'outputFile' , None ) if self.__outputfile: from saphyra.core.readers.versions import TunedData_v1 self.__tunedData = TunedData_v1() checkForUnusedVars(kw) from saphyra import Context self.__context = Context() self.__index_from_cv = None
def __init__(self, **kw): Logger.__init__(self) self.epochs = retrieve_kw(kw, 'epochs', 1000) self.batch_size = retrieve_kw(kw, 'batch_size', 1024) self.lambda_disco = retrieve_kw(kw, 'lambda_disco', 300) self.callbacks = retrieve_kw(kw, 'callbacks', []) self.metrics = retrieve_kw(kw, 'metrics', []) job_auto_config = retrieve_kw(kw, 'job', None) self.sorts = retrieve_kw(kw, 'sorts', range(1)) self.inits = retrieve_kw(kw, 'inits', 1) self.__verbose = retrieve_kw(kw, 'verbose', True) self.__model_generator = retrieve_kw(kw, 'model_generator', None) self.total = 100000 self.background_percent = 0.99 self.test_size = 0.3 # read the job configuration from file if job_auto_config: if type(job_auto_config) is str: MSG_INFO(self, 'Reading job configuration from: %s', job_auto_config) from saphyra.core.readers import JobReader job = JobReader().load(job_auto_config) else: job = job_auto_config # retrive sort/init lists from file self.sorts = job.getSorts() self.inits = job.getInits() self.__models, self.__id_models = job.getModels() self.__jobId = job.id() # get model and tag from model file or lists models = retrieve_kw(kw, 'models', None) if models: self.__models = models self.__id_models = [id for id in range(len(models))] self.__jobId = 0 checkForUnusedVars(kw)
def __init__( self, name, **kw ): Algorithm.__init__( self, name ) self._basepath = retrieve_kw( kw, 'basepath' , '')
def __init__(self, name, **kw): Algorithm.__init__(self, name) self._outputname = retrieve_kw(kw, 'outputname', 'collection.pic') self._event = [] self._event_label = []
def __init__(self, name, **kw): Algorithm.__init__(self, name) self._basepath = retrieve_kw(kw, 'basepath', 'particle') self._energy_bins = retrieve_kw(kw, 'energy_bins', [])