[docs]def__setitem__(self,key:str,value:Any)->None:""" Set a statistic in the logger by key. Parameters ---------- key : str The key for the statistic. value : Any The value to store. Returns ------- None Examples -------- >>> logger = WandbLogger() >>> logger['step'] = 1 """self.log[key]=value
[docs]defadd(self,split:str,stats:Dict[str,Any])->None:""" Add multiple statistics for a given split, prefixing keys with the split name. Parameters ---------- split : str The split name (e.g., 'train', 'test'). stats : dict Dictionary of statistics to add. Returns ------- None Examples -------- >>> logger = WandbLogger() >>> logger.add('train', {'loss': 0.1, 'acc': 0.9}) """fork,vinstats.items():self.log[f"{split}/{k}"]=v
[docs]defget(self)->Dict[str,Any]:""" Retrieve the current statistics dictionary. Returns ------- dict The current statistics log. Examples -------- >>> logger = WandbLogger() >>> logger.clear() >>> logger['step'] = 1 >>> logger.add('train', {'loss': 0.1, 'acc': 0.9}) >>> stats = logger.get() """returnself.log