def test_systematic(self, weights):
        u = torch.rand(weights.shape)

        pyfilter_inds = systematic(weights, u=u, normalized=True).numpy()

        for i in range(weights.shape[0]):
            filterpy_inds = filterpy_systematic_resample(weights[i], u[i])
            assert (pyfilter_inds[i] == filterpy_inds).all()
Exemple #2
0
    def test_SystematicVector(self):
        weights = torch.tensor(np.random.normal(size=300))

        u = np.random.uniform()

        pyfilter_inds = systematic(weights, u=torch.tensor(u))

        filterpy_inds = filterpy_systematic_resample(normalize(weights), u)
        assert (pyfilter_inds.numpy() == filterpy_inds).all()
Exemple #3
0
    def test_SystematicMatrix(self):
        weights = torch.tensor(np.random.normal(size=(10000, 300)))

        u = np.random.uniform(size=(weights.shape[0], 1))

        pyfilter_inds = systematic(weights, u=torch.tensor(u))

        for i in range(weights.shape[0]):
            filterpy_inds = filterpy_systematic_resample(normalize(weights[i]), u[i])
            assert (pyfilter_inds[i].numpy() == filterpy_inds).all()