MCPcopy Create free account
hub / github.com/YeWR/EfficientZero / _phi

Method _phi

core/config.py:349–362  ·  view source on GitHub ↗
(self, x, min, max, set_size: int)

Source from the content-addressed store, hash-verified

347 return self._phi(x, self.reward_support.min, self.reward_support.max, self.reward_support.size)
348
349 def _phi(self, x, min, max, set_size: int):
350 delta = self.value_support.delta
351
352 x.clamp_(min, max)
353 x_low = x.floor()
354 x_high = x.ceil()
355 p_high = x - x_low
356 p_low = 1 - p_high
357
358 target = torch.zeros(x.shape[0], x.shape[1], set_size).to(x.device)
359 x_high_idx, x_low_idx = x_high - min / delta, x_low - min / delta
360 target.scatter_(2, x_high_idx.long().unsqueeze(-1), p_high.unsqueeze(-1))
361 target.scatter_(2, x_low_idx.long().unsqueeze(-1), p_low.unsqueeze(-1))
362 return target
363
364 def get_hparams(self):
365 # get all the hyper-parameters

Callers 2

value_phiMethod · 0.95
reward_phiMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected