Spaces:
Running
Running
Upload Quasar_axrvi_ranker.py
Browse files5127 unmodified lines51285129513051315132513351345135513651375127 unmodified lines}def load_state_dict(self, state: dict) -> None:"""Restore bandit state from a dict produced by state_dict()."""self.t = state.get("t", self.t)self.counts = state.get("counts", self.counts)self.total_reward = state.get("total_reward", self.total_reward)# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ5127 unmodified lines512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505127 unmodified lines}def load_state_dict(self, state: dict) -> None:"""Restore bandit state from a dict produced by state_dict().Merges rather than overwrites: assets present in the checkpoint keeptheir restored stats, while assets in self.asset_ids that are absentfrom the checkpoint (e.g. added after the checkpoint was saved) getfresh defaults instead of being dropped β which previously caused aKeyError in rank_and_gate()'s UCB scoring for any such asset."""self.t = state.get("t", self.t)restored_counts = state.get("counts", {}) or {}restored_reward = state.get("total_reward", {}) or {}self.counts = {a: restored_counts.get(a, 1) for a in self.asset_ids}self.total_reward = {a: restored_reward.get(a, 0.0) for a in self.asset_ids}_new_assets = [a for a in self.asset_ids if a not in restored_counts]if _new_assets:logger.warning(f"[BanditSelector.load_state_dict] Checkpoint predates asset(s) "f"{_new_assets} β initialised with fresh bandit stats.")# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Quasar_axrvi_ranker.py+17-4