def test_gffd_and_uffd_w_input(): torch.manual_seed(SEED) gLd = 0.333 EL = -68.0 EE = -10.0 EI = -86.0 wE = torch.Tensor([[[1.618]]]) wI = torch.Tensor([[[3.141]]]) r_in = torch.Tensor(1, 1).normal_(std=0.1) + 5.0 gffd_expected = gLd + wE * r_in + wI * r_in uffd_expected = (gLd * EL + wE * r_in * EE + wI * r_in * EI) / gffd_expected model = AbstractConvexCell([1], 1) model.gLd[0] = gLd model.EL = EL model.EE = EE model.EI = EI model.set_weightsE(0, wE[0]) model.set_weightsI(0, wI[0]) u_in = model.f_inv(r_in) gffd, uffd = model.compute_gffd_and_uffd(u_in) assert gffd[0][0].tolist() == pytest.approx(gffd_expected[0][0].tolist()) assert uffd[0][0].tolist() == pytest.approx(uffd_expected[0][0].tolist())
def test_dendritic_input(): torch.manual_seed(SEED) r_in = torch.Tensor(1, 5).normal_(std=0.1) + 5.0 model = AbstractConvexCell([3, 2], 1) u_in = model.f_inv(r_in) assert model.dendritic_input(u_in, 0)[0].tolist() == pytest.approx( r_in[0, :3].tolist()) assert model.dendritic_input(u_in, 1)[0].tolist() == pytest.approx( r_in[0, 3:3 + 2].tolist())
def test_input_scale(): torch.manual_seed(SEED) scale_0 = 0.15 scale_1 = 1.05 r_in = torch.Tensor(1, 5).normal_(std=0.1) + 5.0 model = AbstractConvexCell([3, 2], 1) model.set_input_scale(0, scale_0) model.set_input_scale(1, scale_1) u_in = model.f_inv(r_in) assert model.dendritic_input(u_in, 0)[0].tolist() == pytest.approx( (scale_0 * r_in[0, :3]).tolist()) assert model.dendritic_input(u_in, 1)[0].tolist() == pytest.approx( (scale_1 * r_in[0, 3:3 + 2]).tolist())