Ejemplo n.º 1
0
 def update_trial_learning_cos_diff(self) -> None:
     cos_diff = torch.nn.functional.cosine_similarity(
         self.post.phase_acts[self.plus_phase],
         self.post.phase_acts[self.minus_phase],
         dim=0)
     self.cos_diff = utils.clip_float(low=0.01, high=0.99, x=cos_diff)
     self.cos_diff_avg = self.post.spec.avg_dt * (
         cos_diff - self.cos_diff_avg)
Ejemplo n.º 2
0
    def update_trial_learning_averages(self) -> None:
        """Updates the learning averages computed at the end of each trial."""
        cos_diff = torch.nn.functional.cosine_similarity(
            self.acts_p, self.acts_m, dim=0)
        self.cos_diff = utils.clip_float(low=0.01, high=0.99, x=cos_diff)
        self.cos_diff_avg += self.spec.avg_dt * (cos_diff - self.cos_diff_avg)

        acts_p_avg_eff = self.acts_p.mean().item()
        self.units.update_trial_learning_averages(acts_p_avg_eff)
Ejemplo n.º 3
0
def test_clip_float_returns_the_lower_bound_if_x_is_below_it() -> None:
    assert ut.clip_float(low=0.2, high=0.5, x=-1) == 0.2
Ejemplo n.º 4
0
def test_clip_float_returns_x_if_it_is_within_the_range() -> None:
    assert ut.clip_float(low=0.2, high=0.5, x=0.3) == 0.3
Ejemplo n.º 5
0
def test_clip_float_returns_the_upper_bound_if_x_is_above_it() -> None:
    assert ut.clip_float(low=0.2, high=0.5, x=1) == 0.5