def __init__(self, transientAttrs = set(), toPublicAttrs = set(), **kw): "Initialize streamer and declare transient variables." Logger.__init__(self, kw) self.transientAttrs = set(transientAttrs) | {'_readVersion',} self.toPublicAttrs = set(toPublicAttrs) from Gaugi import checkForUnusedVars checkForUnusedVars( kw, self._logger.warning )
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 get_attributes(o, **kw): """ Return attributes from a class or object. """ onlyVars = kw.pop('onlyVars', False) getProtected = kw.pop('getProtected', True) from Gaugi import checkForUnusedVars checkForUnusedVars(kw) return [(a[0] if onlyVars else a) for a in inspect.getmembers(o, lambda a:not(inspect.isroutine(a))) \ if not(a[0].startswith('__') and a[0].endswith('__')) \ and (getProtected or not( a[0].startswith('_') or a[0].startswith('__') ) ) ]
def __init__(self, ignoreAttrs = set(), toProtectedAttrs = set(), ignoreRawChildren = False, **kw ): """ -> ignoreAttrs: not consider this attributes on the dictionary values. -> toProtectedAttrs: change public attributes to protected or private attributes. That is, suppose the dictionary value is 'val' and the class value should be _val or __val, then add toProtectedAttrs = ['_val'] or '__val'. -> ignoreRawChildren: Do not attempt to conver raw children to higher level object. """ Logger.__init__(self, kw) ignoreAttrs = list(set(ignoreAttrs) | RawDictCnv.baseAttrs) import re self.ignoreAttrs = [re.compile(ignoreAttr) for ignoreAttr in ignoreAttrs] self.toProtectedAttrs = set(toProtectedAttrs) self.ignoreRawChildren = ignoreRawChildren from Gaugi import checkForUnusedVars checkForUnusedVars( kw, self._logger.warning )
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)