MCPcopy
hub / github.com/OpenPPL/ppq / __init__

Method __init__

ppq/quantization/algorithm/exprimental.py:25–35  ·  view source on GitHub ↗
(self,  arms: List[float], config: TensorQuantizationConfig)

Source from the content-addressed store, hash-verified

23 quantization scale and offset.
24 """
25 def __init__(self, arms: List[float], config: TensorQuantizationConfig) -> None:
26 if len(arms) < 2: raise ValueError('Can not initialize bandit with less than 2 arms.')
27 self.e = 0.1
28 self.arms = arms
29 self.num_of_arms = len(arms)
30 self.rewards = [EMARecorder() for _ in range(self.num_of_arms)]
31 self.rewards[0].push(1)
32 self.last_selected = 0
33 self.reference = config.scale.clone()
34 self.config = config
35 self.decay = 0.99
36
37 def roll(self) -> int:
38 if random.random() > self.e: selected = random.randint(0, len(self.arms) - 1)

Callers

nothing calls this directly

Calls 2

EMARecorderClass · 0.90
pushMethod · 0.45

Tested by

no test coverage detected